The Battle for Wesnoth  1.19.8+dev
team.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "color_range.hpp"
19 #include "config.hpp"
20 #include "defeat_condition.hpp"
21 #include "game_config.hpp"
22 #include "game_events/fwd.hpp"
23 #include "map/location.hpp"
24 #include "recall_list_manager.hpp"
25 #include "side_controller.hpp"
27 #include "team_shared_vision.hpp"
28 
29 #include <chrono>
30 #include <set>
31 
32 #include <boost/dynamic_bitset.hpp>
33 
34 class game_data;
35 class gamemap;
36 struct color_t;
37 
38 
39 namespace wb {
40  class side_actions;
41 }
42 
43 class shroud_map {
44 public:
45  shroud_map() : enabled_(false), data_() {}
46 
47  void place(int x, int y);
48  bool clear(int x, int y);
49  void reset();
50 
51  bool value(int x, int y) const;
52  bool shared_value(const std::vector<const shroud_map*>& maps, int x, int y) const;
53 
54  bool copy_from(const std::vector<const shroud_map*>& maps);
55 
56  std::string write() const;
57  void read(const std::string& shroud_data);
58  void merge(const std::string& shroud_data);
59 
60  bool enabled() const { return enabled_; }
61  void set_enabled(bool enabled) { enabled_ = enabled; }
62 
63  int width() const;
64  int height() const;
65 private:
66  bool enabled_;
67  std::vector<std::vector<bool>> data_;
68 };
69 
70 /**
71  * This class stores all the data for a single 'side' (in game nomenclature).
72  * E.g., there is only one leader unit per team.
73  */
74 class team
75 {
76 private:
77  struct team_info
78  {
79  team_info();
80  void read(const config &cfg);
81  void write(config& cfg) const;
82  int gold;
84  int income;
87  mutable int minimum_recruit_price;
89  std::set<std::string> can_recruit;
90  std::string team_name;
93  std::string faction;
95  std::string save_id;
96  // 'id' of the current player (not necessarily unique)
97  std::string current_player;
98  std::string countdown_time;
100 
101  std::string flag;
102  std::string flag_icon;
103 
104  std::string id;
105 
107 
108  t_string objectives; /** < Team's objectives for the current level. */
109 
110  /** Set to true when the objectives for this time changes.
111  * Reset to false when the objectives for this team have been
112  * displayed to the user. */
113  mutable bool objectives_changed;
114 
116  bool is_local;
118 
119  side_proxy_controller::type proxy_controller; // when controller == HUMAN, the proxy controller determines what input method is actually used.
120  // proxy controller is an interface property, not gamestate. it is not synced, not known to server.
121  // also not saved in save game file
126  bool no_leader;
127  bool hidden;
128  bool no_turn_confirmation; // Can suppress confirmations when ending a turn.
129 
130  std::string color;
131 
132  int side;
134  bool lost;
135 
138  // TODO: maybe make this integer percentage? I like the float version more but this might cause OOS error because of floating point rounding differences on different hardware.
142  void handle_legacy_share_vision(const config& cfg);
143  };
144 
145  static const int default_team_gold_;
146 
147 public:
148  team();
149  virtual ~team();
150 
151  /**
152  * Stores the attributes recognized by [side]. These should be stripped
153  * from a side's config before using it to create the side's leader.
154  */
155  static const std::set<std::string> attributes;
156  /**
157  * Stores the child tags recognized by [side]. These should be stripped
158  * from a side's config before using it to create the side's leader.
159  */
160  static const std::set<std::string> tags;
161 
162  void build(const config &cfg, const gamemap &map);
163 
164  void write(config& cfg) const;
165 
166  void fix_villages(const gamemap &map);
167  /**
168  * Acquires a village from owner_side.
169  * Pointer fire_event should be the game_data for the game if it is desired to fire an event -- a "capture" event with owner_side variable scoped in will be fired.
170  * For no event, pass it nullptr.
171  * Default is the resources::gamedata pointer.
172  */
174  void lose_village(const map_location&);
175  void clear_villages() { villages_.clear(); }
176  const std::set<map_location>& villages() const { return villages_; }
177  bool owns_village(const map_location& loc) const
178  { return villages_.count(loc) > 0; }
179 
180  int side() const { return info_.side; }
181  int gold() const { return info_.gold; }
182  int start_gold() const { return info_.start_gold; }
184  int village_gold() const { return info_.income_per_village; }
185  int recall_cost() const { return info_.recall_cost; }
186  void set_village_gold(int income) { info_.income_per_village = income; }
187  void set_recall_cost(int cost) { info_.recall_cost = cost; }
188  int total_income() const { return base_income() + static_cast<int>(villages_.size()) * info_.income_per_village; }
189  /** @return The number of unit levels each village can support,
190  i.e. how much upkeep each village can bear. */
191  int village_support() const { return info_.support_per_village; }
192  /** @param support The number of unit levels each village can support */
194  /** Calculate total support capacity, based on support_per_village. */
195  int support() const { return static_cast<int>(villages_.size()) * village_support(); }
196  void new_turn() { info_.gold += total_income(); }
198  void set_gold(int amount) { info_.gold = amount; }
199  void set_start_gold(const int amount) { info_.start_gold = amount; }
200  void spend_gold(const int amount) { info_.gold -= amount; }
201  void set_base_income(int amount) { info_.income = amount - game_config::base_income; }
202  std::chrono::milliseconds countdown_time() const { return countdown_time_; }
203  void set_countdown_time(const std::chrono::milliseconds& amount) const { countdown_time_ = amount; }
204  int action_bonus_count() const { return action_bonus_count_; }
205  void set_action_bonus_count(const int count) { action_bonus_count_ = count; }
207  const recall_list_manager & recall_list() const {return recall_list_;}
208  void set_current_player(const std::string& player)
209  { info_.current_player = player; }
210 
212  void set_scroll_to_leader(bool value) { info_.scroll_to_leader = value; }
213 
214  const std::set<std::string>& recruits() const
215  { return info_.can_recruit; }
216  void add_recruit(const std::string &);
217  void set_recruits(const std::set<std::string>& recruits);
218  int minimum_recruit_price() const;
219  const std::string& last_recruit() const { return last_recruit_; }
220  void last_recruit(const std::string & u_type) { last_recruit_ = u_type; }
221 
222  const std::string& save_id() const { return info_.save_id; }
223  std::string save_id_or_number() const { return info_.save_id.empty() ? std::to_string(info_.side) : info_.save_id; }
224  void set_save_id(const std::string& save_id) { info_.save_id = save_id; }
225  const std::string& current_player() const { return info_.current_player; }
226 
227  void set_objectives(const t_string& new_objectives, bool silently=false);
228  void set_objectives_changed(bool c = true) const { info_.objectives_changed = c; }
230 
231  const t_string& objectives() const { return info_.objectives; }
232  bool objectives_changed() const { return info_.objectives_changed; }
233 
234  bool is_enemy(int n) const {
235  const std::size_t index = std::size_t(n-1);
236  if(index >= enemies_.size()) {
238  }
239  if(index < enemies_.size()) {
240  return enemies_[index];
241  } else {
242  return false;
243  }
244  }
245 
247  const std::string& color() const { return info_.color; }
248  /** @note Call display::reinit_flag_for_side() after calling this */
249  void set_color(const std::string& color) { info_.color = color; }
250  bool is_empty() const { return info_.controller == side_controller::type::none; }
251 
252  bool is_local() const { return !is_empty() && info_.is_local; }
253  bool is_network() const { return !is_empty() && !info_.is_local; }
254 
255  bool is_human() const { return info_.controller == side_controller::type::human; }
256  bool is_ai() const { return info_.controller == side_controller::type::ai; }
257 
258  bool is_local_human() const { return is_human() && is_local(); }
259  bool is_local_ai() const { return is_ai() && is_local(); }
260  bool is_network_human() const { return is_human() && is_network(); }
261  bool is_network_ai() const { return is_ai() && is_network(); }
262 
263  void set_local(bool local) { info_.is_local = local; }
264  void make_human() { info_.controller = side_controller::type::human; }
265  void make_ai() { info_.controller = side_controller::type::ai; }
266  void change_controller(const std::string& new_controller) {
267  info_.controller = side_controller::get_enum(new_controller).value_or(side_controller::type::ai);
268  }
270  void change_controller_by_wml(const std::string& new_controller);
271 
273  bool is_proxy_human() const { return info_.proxy_controller == side_proxy_controller::type::human; }
274  bool is_droid() const { return info_.proxy_controller == side_proxy_controller::type::ai; }
275  bool is_idle() const { return info_.proxy_controller == side_proxy_controller::type::idle; }
276 
277  void make_droid() { info_.proxy_controller = side_proxy_controller::type::ai; }
278  void make_idle() { info_.proxy_controller = side_proxy_controller::type::idle; }
279  void make_proxy_human() { info_.proxy_controller = side_proxy_controller::type::human; }
281 
283 
284  void toggle_droid() { info_.proxy_controller = (info_.proxy_controller == side_proxy_controller::type::ai ) ? side_proxy_controller::type::human : side_proxy_controller::type::ai; }
285  void toggle_idle() { info_.proxy_controller = (info_.proxy_controller == side_proxy_controller::type::idle) ? side_proxy_controller::type::human : side_proxy_controller::type::idle; }
286 
287  const std::string& team_name() const { return info_.team_name; }
288  const t_string &user_team_name() const { return info_.user_team_name; }
289  void change_team(const std::string &name, const t_string &user_name);
290 
291  const std::string& flag() const { return info_.flag; }
292  const std::string& flag_icon() const { return info_.flag_icon; }
293 
294  /** @note Call display::reinit_flag_for_side() after calling this */
295  void set_flag(const std::string& flag) { info_.flag = flag; }
296  void set_flag_icon(const std::string& flag_icon) { info_.flag_icon = flag_icon; }
297 
298  const std::string& side_name() const { return info_.side_name.empty() ? info_.current_player : info_.side_name.str(); }
300  void set_side_name(const t_string& new_name) {info_.side_name = new_name == info_.current_player ? "" : new_name;}
301  const std::string& faction() const { return info_.faction; }
302  const t_string& faction_name() const { return info_.faction_name; }
303  //Returns true if the hex is shrouded/fogged for this side, or
304  //any other ally with shared vision.
305  bool shrouded(const map_location& loc) const;
306  bool fogged(const map_location& loc) const;
307 
308  bool uses_shroud() const { return shroud_.enabled(); }
309  bool uses_fog() const { return fog_.enabled(); }
310  bool fog_or_shroud() const { return uses_shroud() || uses_fog(); }
311  bool clear_shroud(const map_location& loc) { return shroud_.clear(loc.wml_x(),loc.wml_y()); }
313  bool clear_fog(const map_location& loc) { return fog_.clear(loc.wml_x(),loc.wml_y()); }
314  void reshroud() { shroud_.reset(); }
315  void refog() { fog_.reset(); }
316  void set_shroud(bool shroud) { shroud_.set_enabled(shroud); }
317  void set_fog(bool fog) { fog_.set_enabled(fog); }
318  std::string shroud_data() const { return shroud_.write(); }
319 
320  /** Merge a WML shroud map with the shroud data of this player. */
322 
323  bool knows_about_team(std::size_t index) const;
324  /** Records hexes that were cleared of fog via WML. */
325  void add_fog_override(const std::set<map_location> &hexes) { fog_clearer_.insert(hexes.begin(), hexes.end()); }
326  /** Removes the record of hexes that were cleared of fog via WML. */
327  void remove_fog_override(const std::set<map_location> &hexes);
328 
329  bool auto_shroud_updates() const { return auto_shroud_updates_; }
330  void set_auto_shroud_updates(bool value) { auto_shroud_updates_ = value; }
332  bool no_leader() const { return info_.no_leader; }
335  /** sets the defeat condition if @param value is a valid defeat condition, otherwise nothing happes. */
336  void set_defeat_condition_string(const std::string& value) { info_.defeat_cond = defeat_condition::get_enum(value).value_or(info_.defeat_cond); }
337  void have_leader(bool value=true) { info_.no_leader = !value; }
338  bool hidden() const { return info_.hidden; }
339  void set_hidden(bool value) { info_.hidden=value; }
340  bool persistent() const { return info_.persistent; }
341  void set_persistent(bool value) { info_.persistent = value; }
342  void set_lost(bool value=true) { info_.lost = value; }
343  bool lost() const { return info_.lost; }
344 
347  void set_carryover_add(bool value) { info_.carryover_add = value; }
348  bool carryover_add() const { return info_.carryover_add; }
349  void set_carryover_bonus(double value) { info_.carryover_bonus = value; }
350  double carryover_bonus() const { return info_.carryover_bonus; }
351  void set_carryover_gold(int value) { info_.carryover_gold = value; }
352  int carryover_gold() const { return info_.carryover_gold; }
354  const config& variables() const { return info_.variables; }
355 
358 
359  //function which, when given a 1-based side will return the color used by that side.
360  static const color_range get_side_color_range(int side);
361 
362  static color_t get_side_color(int side);
363  static color_t get_minimap_color(int side);
364 
365  static std::string get_side_color_id(unsigned side);
366  static const t_string get_side_color_name_for_UI(unsigned side);
367  static std::string get_side_color_id_from_config(const config& cfg);
368  static std::string get_side_highlight_pango(int side);
369 
370  void log_recruitable() const;
371 
372  /** clear the shroud, fog, and enemies cache for all teams*/
373  static void clear_caches();
374 
375  /** get the whiteboard planned actions for this team */
376  std::shared_ptr<wb::side_actions> get_side_actions() const { return planned_actions_; }
377 
378  config to_config() const;
379 
380  bool share_maps() const { return info_.share_vision != team_shared_vision::type::none ; }
381  bool share_view() const { return info_.share_vision == team_shared_vision::type::all; }
383 
384  void set_share_vision(const std::string& vision_status) {
385  info_.share_vision = team_shared_vision::get_enum(vision_status).value_or(team_shared_vision::type::all);
386  clear_caches();
387  }
388 
390  info_.share_vision = vision_status;
391  clear_caches();
392  }
393 
395  {
397  }
398  std::string allied_human_teams() const;
399 
400  bool chose_random() const
401  {
402  return info_.chose_random;
403  }
404 
405 private:
406 
407  const std::vector<const shroud_map*>& ally_shroud(const std::vector<team>& teams) const;
408  const std::vector<const shroud_map*>& ally_fog(const std::vector<team>& teams) const;
409 
410  std::set<map_location> villages_;
411 
413  /** Stores hexes that have been cleared of fog via WML. */
414  std::set<map_location> fog_clearer_;
415 
417 
419 
420  mutable std::chrono::milliseconds countdown_time_;
422 
424  std::string last_recruit_;
425 
426 private:
427  void calculate_enemies(std::size_t index) const;
428  bool calculate_is_enemy(std::size_t index) const;
429  mutable boost::dynamic_bitset<> enemies_;
430 
431  mutable std::vector<const shroud_map*> ally_shroud_, ally_fog_;
432 
433  /**
434  * Whiteboard planned actions for this team.
435  */
436  std::shared_ptr<wb::side_actions> planned_actions_;
437 };
438 
439 //function which will validate a side. Throws game::game_error
440 //if the side is invalid
441 void validate_side(int side); //throw game::game_error
map_location loc
Definition: move.cpp:172
A color range definition is made of four reference RGB colors, used for calculating conversions from ...
Definition: color_range.hpp:49
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:158
Encapsulates the map of the game.
Definition: map.hpp:172
This class encapsulates the recall list of a team.
bool copy_from(const std::vector< const shroud_map * > &maps)
Definition: team.cpp:912
int height() const
Definition: team.cpp:762
void read(const std::string &shroud_data)
Definition: team.cpp:877
void set_enabled(bool enabled)
Definition: team.hpp:61
shroud_map()
Definition: team.hpp:45
bool enabled() const
Definition: team.hpp:60
std::vector< std::vector< bool > > data_
Definition: team.hpp:67
void place(int x, int y)
Definition: team.cpp:792
int width() const
Definition: team.cpp:757
bool shared_value(const std::vector< const shroud_map * > &maps, int x, int y) const
Definition: team.cpp:840
void merge(const std::string &shroud_data)
Definition: team.cpp:896
bool value(int x, int y) const
Definition: team.cpp:820
std::string write() const
Definition: team.cpp:861
void reset()
Definition: team.cpp:809
bool enabled_
Definition: team.hpp:66
bool clear(int x, int y)
Definition: team.cpp:770
bool empty() const
Definition: tstring.hpp:195
const std::string & str() const
Definition: tstring.hpp:199
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:75
static std::string get_side_highlight_pango(int side)
Definition: team.cpp:1020
bool uses_shroud() const
Definition: team.hpp:308
void set_action_bonus_count(const int count)
Definition: team.hpp:205
int carryover_gold() const
Definition: team.hpp:352
const std::string & color() const
Definition: team.hpp:247
bool clear_shroud(const map_location &loc)
Definition: team.hpp:311
void have_leader(bool value=true)
Definition: team.hpp:337
bool is_ai() const
Definition: team.hpp:256
static color_t get_minimap_color(int side)
Definition: team.cpp:954
void build(const config &cfg, const gamemap &map)
Definition: team.cpp:355
bool no_turn_confirmation() const
Definition: team.hpp:356
void set_carryover_percentage(int value)
Definition: team.hpp:345
void fix_villages(const gamemap &map)
Definition: team.cpp:414
bool is_proxy_human() const
Definition: team.hpp:273
config & variables()
Definition: team.hpp:353
const std::string & side_name() const
Definition: team.hpp:298
recall_list_manager recall_list_
Definition: team.hpp:423
int side() const
Definition: team.hpp:180
game_events::pump_result_t get_village(const map_location &, const int owner_side, game_data *fire_event)
Acquires a village from owner_side.
Definition: team.cpp:426
bool is_human() const
Definition: team.hpp:255
void set_countdown_time(const std::chrono::milliseconds &amount) const
Definition: team.hpp:203
void set_flag_icon(const std::string &flag_icon)
Definition: team.hpp:296
void set_scroll_to_leader(bool value)
Definition: team.hpp:212
int support() const
Calculate total support capacity, based on support_per_village.
Definition: team.hpp:195
const std::string & faction() const
Definition: team.hpp:301
int village_support() const
Definition: team.hpp:191
std::vector< const shroud_map * > ally_shroud_
Definition: team.hpp:431
int recall_cost() const
Definition: team.hpp:185
static const color_range get_side_color_range(int side)
Definition: team.cpp:937
void set_objectives_changed(bool c=true) const
Definition: team.hpp:228
void set_shroud(bool shroud)
Definition: team.hpp:316
bool is_droid() const
Definition: team.hpp:274
bool fog_or_shroud() const
Definition: team.hpp:310
void change_proxy(side_proxy_controller::type proxy)
Definition: team.hpp:282
bool auto_shroud_updates() const
Definition: team.hpp:329
void set_local(bool local)
Definition: team.hpp:263
const std::string & current_player() const
Definition: team.hpp:225
void set_recruits(const std::set< std::string > &recruits)
Definition: team.cpp:459
const std::string & team_name() const
Definition: team.hpp:287
bool objectives_changed() const
Definition: team.hpp:232
void set_carryover_gold(int value)
Definition: team.hpp:351
bool is_local() const
Definition: team.hpp:252
void set_carryover_bonus(double value)
Definition: team.hpp:349
static std::string get_side_color_id_from_config(const config &cfg)
Definition: team.cpp:1000
bool is_local_human() const
Definition: team.hpp:258
std::chrono::milliseconds countdown_time_
Definition: team.hpp:420
void merge_shroud_map_data(const std::string &shroud_data)
Merge a WML shroud map with the shroud data of this player.
Definition: team.hpp:321
bool no_leader() const
Definition: team.hpp:332
void toggle_idle()
Definition: team.hpp:285
void refog()
Definition: team.hpp:315
bool clear_fog(const map_location &loc)
Definition: team.hpp:313
int village_gold() const
Definition: team.hpp:184
bool is_enemy(int n) const
Definition: team.hpp:234
config to_config() const
Definition: team.cpp:1035
team_shared_vision::type share_vision() const
Definition: team.hpp:382
void set_auto_shroud_updates(bool value)
Definition: team.hpp:330
int action_bonus_count() const
Definition: team.hpp:204
shroud_map fog_
Definition: team.hpp:412
bool owns_village(const map_location &loc) const
Definition: team.hpp:177
bool calculate_is_enemy(std::size_t index) const
Definition: team.cpp:509
const std::set< map_location > & villages() const
Definition: team.hpp:176
const recall_list_manager & recall_list() const
Definition: team.hpp:207
void set_current_player(const std::string &player)
Definition: team.hpp:208
void change_controller(side_controller::type controller)
Definition: team.hpp:269
bool knows_about_team(std::size_t index) const
Definition: team.cpp:693
const t_string & objectives() const
Definition: team.hpp:231
void change_team(const std::string &name, const t_string &user_name)
Definition: team.cpp:606
int gold() const
Definition: team.hpp:181
static const t_string get_side_color_name_for_UI(unsigned side)
Definition: team.cpp:988
team()
Definition: team.cpp:333
const t_string & faction_name() const
Definition: team.hpp:302
defeat_condition::type defeat_cond() const
Definition: team.hpp:333
void set_objectives(const t_string &new_objectives, bool silently=false)
Definition: team.cpp:631
t_string side_name_tstr() const
Definition: team.hpp:299
bool carryover_add() const
Definition: team.hpp:348
std::string shroud_data() const
Definition: team.hpp:318
static const std::set< std::string > tags
Stores the child tags recognized by [side].
Definition: team.hpp:160
void clear_proxy()
Definition: team.hpp:280
void handle_legacy_share_vision(const config &cfg)
Definition: team.hpp:394
int carryover_percentage() const
Definition: team.hpp:346
void write(config &cfg) const
Definition: team.cpp:393
static std::string get_side_color_id(unsigned side)
Definition: team.cpp:961
bool is_network_ai() const
Definition: team.hpp:261
bool is_network() const
Definition: team.hpp:253
std::vector< const shroud_map * > ally_fog_
Definition: team.hpp:431
int total_income() const
Definition: team.hpp:188
void set_persistent(bool value)
Definition: team.hpp:341
void reset_objectives_changed() const
Definition: team.hpp:229
void set_recall_cost(int cost)
Definition: team.hpp:187
void set_side_name(const t_string &new_name)
Definition: team.hpp:300
void set_start_gold(const int amount)
Definition: team.hpp:199
team_info info_
Definition: team.hpp:418
void reshroud()
Definition: team.hpp:314
const std::string & save_id() const
Definition: team.hpp:222
static const int default_team_gold_
Definition: team.hpp:145
void set_carryover_add(bool value)
Definition: team.hpp:347
bool is_local_ai() const
Definition: team.hpp:259
void calculate_enemies(std::size_t index) const
Definition: team.cpp:498
void add_recruit(const std::string &)
Definition: team.cpp:469
side_controller::type controller() const
Definition: team.hpp:246
bool is_idle() const
Definition: team.hpp:275
int minimum_recruit_price() const
Definition: team.cpp:476
double carryover_bonus() const
Definition: team.hpp:350
void make_droid()
Definition: team.hpp:277
void change_controller(const std::string &new_controller)
Definition: team.hpp:266
void make_ai()
Definition: team.hpp:265
void add_fog_override(const std::set< map_location > &hexes)
Records hexes that were cleared of fog via WML.
Definition: team.hpp:325
virtual ~team()
Definition: team.cpp:351
static void clear_caches()
clear the shroud, fog, and enemies cache for all teams
Definition: team.cpp:619
std::shared_ptr< wb::side_actions > get_side_actions() const
get the whiteboard planned actions for this team
Definition: team.hpp:376
bool auto_shroud_updates_
Definition: team.hpp:416
bool share_maps() const
Definition: team.hpp:380
void set_defeat_condition(defeat_condition::type value)
Definition: team.hpp:334
std::set< map_location > fog_clearer_
Stores hexes that have been cleared of fog via WML.
Definition: team.hpp:414
bool is_network_human() const
Definition: team.hpp:260
std::string allied_human_teams() const
Definition: team.cpp:1043
int action_bonus_count_
Definition: team.hpp:421
bool shrouded(const map_location &loc) const
Definition: team.cpp:640
void set_fog(bool fog)
Definition: team.hpp:317
const config & variables() const
Definition: team.hpp:354
std::set< map_location > villages_
Definition: team.hpp:410
void set_color(const std::string &color)
Definition: team.hpp:249
void make_proxy_human()
Definition: team.hpp:279
std::chrono::milliseconds countdown_time() const
Definition: team.hpp:202
int start_gold() const
Definition: team.hpp:182
const std::string & flag_icon() const
Definition: team.hpp:292
shroud_map shroud_
Definition: team.hpp:412
void make_human()
Definition: team.hpp:264
std::string save_id_or_number() const
Definition: team.hpp:223
void spend_gold(const int amount)
Definition: team.hpp:200
const std::vector< const shroud_map * > & ally_fog(const std::vector< team > &teams) const
Definition: team.cpp:680
void clear_villages()
Definition: team.hpp:175
bool get_scroll_to_leader() const
Definition: team.hpp:211
side_proxy_controller::type proxy_controller() const
Definition: team.hpp:272
int base_income() const
Definition: team.hpp:183
bool uses_fog() const
Definition: team.hpp:309
static color_t get_side_color(int side)
Definition: team.cpp:949
void set_flag(const std::string &flag)
Definition: team.hpp:295
static const std::set< std::string > attributes
Stores the attributes recognized by [side].
Definition: team.hpp:155
bool persistent() const
Definition: team.hpp:340
const std::string & flag() const
Definition: team.hpp:291
bool hidden() const
Definition: team.hpp:338
std::string last_recruit_
Definition: team.hpp:424
void get_shared_maps()
recall_list_manager & recall_list()
Definition: team.hpp:206
void set_village_gold(int income)
Definition: team.hpp:186
void set_hidden(bool value)
Definition: team.hpp:339
void set_village_support(int support)
Definition: team.hpp:193
void last_recruit(const std::string &u_type)
Definition: team.hpp:220
void set_defeat_condition_string(const std::string &value)
sets the defeat condition if
Definition: team.hpp:336
const std::string & last_recruit() const
Definition: team.hpp:219
bool get_disallow_observers() const
Definition: team.hpp:331
void set_no_turn_confirmation(bool value)
Definition: team.hpp:357
std::shared_ptr< wb::side_actions > planned_actions_
Whiteboard planned actions for this team.
Definition: team.hpp:436
bool share_view() const
Definition: team.hpp:381
void set_save_id(const std::string &save_id)
Definition: team.hpp:224
const std::set< std::string > & recruits() const
Definition: team.hpp:214
const t_string & user_team_name() const
Definition: team.hpp:288
void make_idle()
Definition: team.hpp:278
void lose_village(const map_location &)
Definition: team.cpp:452
void set_share_vision(const std::string &vision_status)
Definition: team.hpp:384
void set_base_income(int amount)
Definition: team.hpp:201
void set_share_vision(team_shared_vision::type vision_status)
Definition: team.hpp:389
boost::dynamic_bitset enemies_
Definition: team.hpp:429
void remove_fog_override(const std::set< map_location > &hexes)
Removes the record of hexes that were cleared of fog via WML.
Definition: team.cpp:734
bool fogged(const map_location &loc) const
Definition: team.cpp:649
void set_lost(bool value=true)
Definition: team.hpp:342
bool is_empty() const
Definition: team.hpp:250
bool lost() const
Definition: team.hpp:343
void place_shroud(const map_location &loc)
Definition: team.hpp:312
void change_controller_by_wml(const std::string &new_controller)
Definition: team.cpp:573
void set_gold(int amount)
Definition: team.hpp:198
bool chose_random() const
Definition: team.hpp:400
void log_recruitable() const
Definition: team.cpp:1025
void toggle_droid()
Definition: team.hpp:284
void new_turn()
Definition: team.hpp:196
const std::vector< const shroud_map * > & ally_shroud(const std::vector< team > &teams) const
Definition: team.cpp:667
Definitions for the interface to Wesnoth Markup Language (WML).
std::tuple< bool, bool > pump_result_t
Definition: fwd.hpp:29
bool fire_event(const ui_event event, const std::vector< std::pair< widget *, ui_event >> &event_chain, widget *dispatcher, widget *w, F &&... params)
Helper function for fire_event.
std::size_t index(std::string_view str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:70
Definition: display.hpp:45
The basic class for representing 8-bit RGB or RGBA colour values.
Definition: color.hpp:59
Encapsulates the map of the game.
Definition: location.hpp:45
int wml_y() const
Definition: location.hpp:184
int wml_x() const
Definition: location.hpp:183
static constexpr utils::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
Definition: enum_base.hpp:57
std::string color
Definition: team.hpp:130
double carryover_bonus
Definition: team.hpp:139
int carryover_gold
Definition: team.hpp:140
bool chose_random
Definition: team.hpp:125
std::string team_name
Definition: team.hpp:90
void read(const config &cfg)
Definition: team.cpp:171
t_string user_team_name
Definition: team.hpp:91
int minimum_recruit_price
Definition: team.hpp:87
t_string faction_name
Definition: team.hpp:94
config variables
Definition: team.hpp:141
std::string countdown_time
Definition: team.hpp:98
void handle_legacy_share_vision(const config &cfg)
Definition: team.cpp:271
std::string flag
Definition: team.hpp:101
std::string current_player
Definition: team.hpp:97
bool is_local
Definition: team.hpp:116
side_proxy_controller::type proxy_controller
Definition: team.hpp:119
int carryover_percentage
Definition: team.hpp:136
t_string side_name
Definition: team.hpp:92
bool scroll_to_leader
Definition: team.hpp:106
t_string objectives
Definition: team.hpp:108
int action_bonus_count
Definition: team.hpp:99
int start_gold
Definition: team.hpp:83
std::string id
Definition: team.hpp:104
void write(config &cfg) const
Definition: team.cpp:284
std::string faction
Definition: team.hpp:93
bool carryover_add
Definition: team.hpp:137
bool no_turn_confirmation
Definition: team.hpp:128
bool disallow_observers
Definition: team.hpp:123
std::string flag_icon
Definition: team.hpp:102
int recall_cost
Definition: team.hpp:88
bool no_leader
Definition: team.hpp:126
bool persistent
Definition: team.hpp:133
bool allow_player
Definition: team.hpp:124
side_controller::type controller
Definition: team.hpp:115
int support_per_village
Definition: team.hpp:86
defeat_condition::type defeat_cond
Definition: team.hpp:117
int income_per_village
Definition: team.hpp:85
std::string save_id
Definition: team.hpp:95
std::set< std::string > can_recruit
Definition: team.hpp:89
bool objectives_changed
< Team's objectives for the current level.
Definition: team.hpp:113
team_shared_vision::type share_vision
Definition: team.hpp:122
void validate_side(int side)
Definition: team.cpp:746
mock_char c
static map_location::direction n