Freeciv21
Develop your civilization from humble roots to a global empire
mood.cpp
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 
14 // common
15 #include "fc_types.h"
16 #include "game.h"
17 #include "player.h"
18 
19 #include "mood.h"
20 
24 enum mood_type player_mood(struct player *pplayer)
25 {
26  if (pplayer->last_war_action >= 0
27  && pplayer->last_war_action + WAR_MOOD_LASTS >= game.info.turn) {
28  players_iterate(other)
29  {
30  struct player_diplstate *us, *them;
31 
32  us = player_diplstate_get(pplayer, other);
33  them = player_diplstate_get(other, pplayer);
34 
35  if (us->type == DS_WAR || us->has_reason_to_cancel > 0
36  || them->has_reason_to_cancel > 0) {
37  return MOOD_COMBAT;
38  }
39  }
41  }
42 
43  return MOOD_PEACEFUL;
44 }
struct civ_game game
Definition: game.cpp:47
enum mood_type player_mood(struct player *pplayer)
What is the player mood?
Definition: mood.cpp:24
#define WAR_MOOD_LASTS
Definition: mood.h:16
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
Definition: player.cpp:288
#define players_iterate_end
Definition: player.h:520
#define players_iterate(_pplayer)
Definition: player.h:514
struct packet_game_info info
Definition: game.h:80
int has_reason_to_cancel
Definition: player.h:197
enum diplstate_type type
Definition: player.h:193
Definition: player.h:231
int last_war_action
Definition: player.h:252