The Battle for Wesnoth  1.17.0-dev
types.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2021
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 "gettext.hpp"
19 #include "utils/make_enum.hpp"
20 #include "map/location.hpp"
21 #include "movetype.hpp"
22 #include "units/race.hpp"
23 #include "units/attack_type.hpp"
24 #include "units/alignment.hpp"
25 #include "units/type_error.hpp"
26 #include "game_config_view.hpp"
27 #include <memory>
28 #include <array>
29 #include <map>
30 #include <set>
31 #include <string>
32 #include <vector>
33 
34 class unit_ability_list;
35 class unit_animation;
37 
38 typedef std::map<std::string, movetype> movement_type_map;
39 
40 
41 /**
42  * A single unit type that the player may recruit.
43  * Individual units are defined by the unit class.
44  */
45 class unit_type
46 {
47 private:
48  struct defaut_ctor_t {};
49  unit_type(defaut_ctor_t, const config& cfg, const std::string & parent_id);
50 
51 public:
53  /**
54  * Creates a unit type for the given config, but delays its build
55  * till later.
56  * @note @a cfg is not copied, so it has to point to some permanent
57  * storage, that is, a child of unit_type_data::unit_cfg.
58  */
59  explicit unit_type(const config &cfg, const std::string & parent_id="");
60  /**
61  * Creates a unit type for the given config, but delays its build
62  * till later.
63  * @note @a cfg is copied
64  */
65  explicit unit_type(config && cfg, const std::string & parent_id="");
66  unit_type();
67  unit_type(const unit_type& o);
68  unit_type(unit_type&& o) = default;
69 
70  ~unit_type();
71 
72  /**
73  * Records the status of the lazy building of unit types.
74  * These are in order of increasing levels of being built.
75  * HELP_INDEX is already defined in a windows header under some conditions
76  */
78 
79  /**
80  * Validate the id argument.
81  * Replaces invalid characters in the reference with underscores.
82  * @param id The proposed id for a unit_type.
83  * @throw error if id starts with a space.
84  */
85  static void check_id(std::string& id);
86 
87 private: // These will be called by build().
88  /** Load data into an empty unit_type (build to FULL). */
89  void build_full(const movement_type_map &movement_types,
90  const race_map &races, const config_array_view &traits);
91  /** Partially load data into an empty unit_type (build to HELP_INDEXED). */
92  void build_help_index(const movement_type_map &movement_types,
93  const race_map &races, const config_array_view &traits);
94  /** Load the most needed data into an empty unit_type (build to CREATE). */
95  void build_created();
96 
97  typedef std::map<std::string,unit_type> variations_map;
98 public:
99  /** Performs a build of this to the indicated stage. */
100  void build(BUILD_STATUS status, const movement_type_map &movement_types,
101  const race_map &races, const config_array_view &traits);
102  /**
103  * Performs a build of this to the indicated stage.
104  * (This does not logically change the unit type, so allow const access.)
105  */
106  void build(BUILD_STATUS status, const movement_type_map &movement_types,
107  const race_map &races, const config_array_view &traits) const
108  { const_cast<unit_type *>(this)->build(status, movement_types, races, traits); }
109 
110 
111  /** Get the advancement tree
112  * @return A set of ids of all unit_type objects that this unit_type can
113  * directly or indirectly advance to.
114  */
115  std::set<std::string> advancement_tree() const;
116 
117  /** A vector of unit_type ids that this unit_type can advance to. */
118  const std::vector<std::string>& advances_to() const { return advances_to_; }
119  /** A vector of unit_type ids that can advance to this unit_type. */
120  const std::vector<std::string> advances_from() const;
121 
122  /** Returns two iterators pointing to a range of AMLA configs. */
124  { return get_cfg().child_range("advancement"); }
125 
126  /**
127  * Returns a gendered variant of this unit_type.
128  * @param gender "male" or "female".
129  */
130  const unit_type& get_gender_unit_type(std::string gender) const;
131  /** Returns a gendered variant of this unit_type based on the given parameter. */
132  const unit_type& get_gender_unit_type(unit_race::GENDER gender) const;
133 
134  const unit_type& get_variation(const std::string& id) const;
135  /** Info on the type of unit that the unit reanimates as. */
136  const std::string& undead_variation() const { return undead_variation_; }
137 
138  unsigned int num_traits() const { return num_traits_; }
139 
140  /** The name of the unit in the current language setting. */
141  const t_string& type_name() const { return type_name_; }
142 
143  /** The id for this unit_type. */
144  const std::string& id() const { return id_; }
145  /** A variant on id() that is more descriptive, for use with message logging. */
146  const std::string log_id() const { return id_ + debug_id_; }
147  /** The id of the original type from which this (variation) descended. */
148  const std::string& parent_id() const { return parent_id_; }
149  /** The id of this variation; empty if it's a gender variation or a base unit. */
150  const std::string& variation_id() const { return variation_id_; }
151  // NOTE: this used to be a const object reference, but it messed up with the
152  // translation engine upon changing the language in the same session.
153  t_string unit_description() const;
154  /**
155  * Returns only the notes defined by [unit_type][special_note] tags, excluding
156  * any that would be found from abilities, attacks, etc.
157  */
158  std::vector<t_string> direct_special_notes() const { return special_notes_; }
159  /**
160  * Returns all notes that should be displayed in the help page for this type,
161  * including those found in abilities and attacks.
162  */
163  std::vector<t_string> special_notes() const;
164  int hitpoints() const { return hitpoints_; }
165  double hp_bar_scaling() const { return hp_bar_scaling_; }
166  double xp_bar_scaling() const { return xp_bar_scaling_; }
167  int level() const { return level_; }
168  int recall_cost() const { return recall_cost_;}
169  int movement() const { return movement_; }
170  int vision() const { return vision_ < 0 ? movement() : vision_; }
171  /** If @a base_value is set to true, do not fall back to movement(). */
172  int vision(bool base_value) const { return base_value ? vision_ : vision(); }
173  int jamming() const {return jamming_; }
174  int max_attacks() const { return max_attacks_; }
175  int cost() const { return cost_; }
176  const std::string& default_variation() const { return default_variation_; }
177  const t_string& variation_name() const { return variation_name_; }
178  const std::string& usage() const { return usage_; }
179  const std::string& image() const { return image_; }
180  const std::string& icon() const { return icon_; }
181  const std::string &small_profile() const { return small_profile_; }
182  const std::string &big_profile() const { return profile_; }
183  std::string halo() const { return get_cfg()["halo"]; }
184  std::string ellipse() const { return get_cfg()["ellipse"]; }
185  bool generate_name() const { return get_cfg()["generate_name"].to_bool(true); }
186  const std::vector<unit_animation>& animations() const;
187 
188  const std::string& flag_rgb() const;
189 
190  const_attack_itors attacks() const;
191  const movetype & movement_type() const { return movement_type_; }
192 
193  int experience_needed(bool with_acceleration=true) const;
194 
195  using ALIGNMENT = UNIT_ALIGNMENT;
196 
197  ALIGNMENT alignment() const { return alignment_; }
198  static std::string alignment_description(ALIGNMENT align, unit_race::GENDER gender = unit_race::MALE);
199 
201  {
202  explicit ability_metadata(const config& cfg);
203 
204  std::string id;
205 
208 
211 
214 
219  };
220 
221  const std::vector<ability_metadata>& abilities_metadata() const { return abilities_; }
222 
223  /** Some extra abilities that may be gained through AMLA advancements. */
224  const std::vector<ability_metadata>& adv_abilities_metadata() const { return adv_abilities_; }
225 
226  bool can_advance() const { return !advances_to_.empty(); }
227 
228  bool musthave_status(const std::string& status) const;
229 
230  bool has_zoc() const { return zoc_; }
231 
232  bool has_ability_by_id(const std::string& ability) const;
233  std::vector<std::string> get_ability_list() const;
234 
236  { return possible_traits_.child_range("trait"); }
237 
238  const config& abilities_cfg() const
239  { return get_cfg().child_or_empty("abilities"); }
240 
242  { return get_cfg().child_range("advancement"); }
243 
245  { return get_cfg().child_range("event"); }
246 
247  bool has_random_traits() const;
248 
249  /**
250  * The returned vector will not be empty, provided this has been built
251  * to the HELP_INDEXED status.
252  */
253  const std::vector<unit_race::GENDER>& genders() const { return genders_; }
254  bool has_gender_variation(const unit_race::GENDER gender) const
255  {
256  return std::find(genders_.begin(), genders_.end(), gender) != genders_.end();
257  }
258 
259  std::vector<std::string> variations() const;
260  const variations_map& variation_types() const {return variations_; }
261 
262  /**
263  * @param variation_id The id of the variation we search for.
264  * @return Whether one of the type's variations' (or the
265  * siblings' if the unit_type is a variation
266  * itself) id matches @a variation_id.
267  */
268  bool has_variation(const std::string& variation_id) const;
269 
270  /**
271  * Whether the unit type has at least one help-visible variation.
272  */
273  bool show_variations_in_help() const;
274 
275  /** Returns the ID of this type's race without the need to build the type. */
276  std::string race_id() const { return get_cfg()["race"]; } //race_->id(); }
277  /**
278  * Never returns nullptr, but may point to the null race.
279  * Requires building to the HELP_INDEXED status to get the correct race.
280  */
281  const unit_race* race() const { return race_; }
282  bool hide_help() const;
283  bool do_not_list() const { return do_not_list_; }
284 
285  const config &get_cfg() const
286  {
287  if(built_cfg_) {
288  return *built_cfg_;
289  }
290  assert(cfg_);
291  return *cfg_;
292  }
293 
294  /**
295  * Gets resistance while considering custom WML abilities.
296  * Attention: Filters in resistance-abilities will be ignored.
297  */
298  int resistance_against(const std::string& damage_name, bool attacker) const;
299 
300  void apply_scenario_fix(const config& cfg);
301  void remove_scenario_fixes();
302 private:
303 
304  /** Identical to unit::resistance_filter_matches. */
305  bool resistance_filter_matches(const config& cfg,bool attacker,const std::string& damage_name, int res) const;
306 
307 private:
309  if(!built_cfg_) {
310  built_cfg_ = std::make_unique<config>(*cfg_);
311  }
312  return *built_cfg_;
313  }
314  void fill_variations();
316  std::unique_ptr<unit_type> create_sub_type(const config& var_cfg, bool default_inherit);
317 
318  unit_type& operator=(const unit_type& o) = delete;
319 
320  const config* cfg_;
321  friend class unit_type_data;
322  mutable std::unique_ptr<config> built_cfg_;
323  mutable bool has_cfg_build_;
325 
326  std::string id_;
327  /** A suffix for id_, used when logging messages. */
328  std::string debug_id_;
329  /** The id of the top ancestor of this unit_type. */
330  std::string parent_id_;
331  /** from [base_unit] */
332  std::string base_unit_id_;
335  std::vector<t_string> special_notes_;
338  int level_;
341  int vision_;
342  int jamming_;
344  int cost_;
345  std::string usage_;
346  std::string undead_variation_;
347 
348  std::string image_;
349  std::string icon_;
350  std::string small_profile_;
351  std::string profile_;
352  std::string flag_rgb_;
353 
354  unsigned int num_traits_;
355 
356  std::array<std::unique_ptr<unit_type>, 2> gender_types_;
357 
358  variations_map variations_;
359  std::string default_variation_;
360  std::string variation_id_;
362 
363  /** Never nullptr, but may point to the null race. */
364  const unit_race* race_;
365 
366  std::vector<ability_metadata> abilities_, adv_abilities_;
367 
369 
370  std::vector<std::string> advances_to_;
372 
373 
375 
377 
379 
380  std::vector<unit_race::GENDER> genders_;
381 
382  // animations are loaded only after the first animations() call
383  mutable std::vector<unit_animation> animations_;
384 
386 };
387 
389 {
390 public:
391  unit_type_data(const unit_type_data&) = delete;
392  unit_type_data& operator=(const unit_type_data&) = delete;
393 
394  unit_type_data();
395 
396  typedef std::map<std::string,unit_type> unit_type_map;
397 
398  const unit_type_map &types() const { return types_; }
399  const race_map &races() const { return races_; }
400  config_array_view traits() const { return units_cfg().child_range("trait"); }
401  void set_config(const game_config_view &cfg);
402 
403  /** Finds a unit_type by its id() and makes sure it is built to the specified level. */
404  const unit_type *find(const std::string &key, unit_type::BUILD_STATUS status = unit_type::FULL) const;
405  void check_types(const std::vector<std::string>& types) const;
406  const unit_race *find_race(const std::string &) const;
407 
408  /** Makes sure the all unit_types are built to the specified level. */
409  void build_all(unit_type::BUILD_STATUS status);
410  /** Makes sure the provided unit_type is built to the specified level. */
411  void build_unit_type(const unit_type & ut, unit_type::BUILD_STATUS status) const;
412 
413  /** Checks if the [hide_help] tag contains these IDs. */
414  bool hide_help(const std::string &type_id, const std::string &race_id) const;
415 
416  void apply_scenario_fix(const config& cfg);
417  void remove_scenario_fixes();
418 private:
419  /** Parses the [hide_help] tag. */
420  void read_hide_help(const config &cfg);
421 
422  void clear();
423 
424  void apply_base_unit(unit_type& type, std::vector<std::string>& base_tree);
425 
426  mutable unit_type_map types_;
429 
430  /** True if [hide_help] contains a 'all=yes' at its root. */
432  // vectors containing the [hide_help] and its sub-tags [not]
433  std::vector< std::set<std::string>> hide_help_type_;
434  std::vector< std::set<std::string>> hide_help_race_;
435 
436  const game_config_view& units_cfg() const { return units_cfg_; }
439 };
440 
442 
443 void adjust_profile(std::string& profile);
444 
446  unit_experience_accelerator(int modifier);
448  static int get_acceleration();
449 private:
451 };
452 
453 /**
454  * Common logic for unit_type::special_notes() and unit::special_notes(). Adds
455  * any notes from the sources given as arguments, and filters out duplicates.
456  *
457  * @return the special notes for a unit or unit_type.
458  */
459 std::vector<t_string> combine_special_notes(const std::vector<t_string> direct, const config& abilities, const_attack_itors attacks, const movetype& mt);
int jamming_
Definition: types.hpp:342
std::vector< attack_ptr > attack_list
std::string parent_id_
The id of the top ancestor of this unit_type.
Definition: types.hpp:330
int experience_needed_
Definition: types.hpp:371
const std::string & parent_id() const
The id of the original type from which this (variation) descended.
Definition: types.hpp:148
UNIT_ALIGNMENT ALIGNMENT
Definition: types.hpp:195
bool has_cfg_build_
Definition: types.hpp:323
bool do_not_list_
Definition: types.hpp:368
unit_type::BUILD_STATUS build_status_
Definition: types.hpp:438
std::map< std::string, unit_type > unit_type_map
Definition: types.hpp:396
int vision(bool base_value) const
If base_value is set to true, do not fall back to movement().
Definition: types.hpp:172
std::string default_variation_
Definition: types.hpp:359
std::string flag_rgb_
Definition: types.hpp:352
bool generate_name() const
Definition: types.hpp:185
ALIGNMENT alignment_
Definition: types.hpp:374
t_string variation_name_
Definition: types.hpp:361
std::string profile_
Definition: types.hpp:351
config_array_view traits() const
Definition: types.hpp:400
void build(BUILD_STATUS status, const movement_type_map &movement_types, const race_map &races, const config_array_view &traits)
Performs a build of this to the indicated stage.
Definition: types.cpp:421
config::const_child_itors events() const
Definition: types.hpp:244
const std::string & big_profile() const
Definition: types.hpp:182
std::string debug_id_
A suffix for id_, used when logging messages.
Definition: types.hpp:328
int hitpoints_
Definition: types.hpp:336
const std::vector< std::string > & advances_to() const
A vector of unit_type ids that this unit_type can advance to.
Definition: types.hpp:118
int recall_cost_
Definition: types.hpp:339
std::string variation_id_
Definition: types.hpp:360
const std::string & flag_rgb() const
Definition: types.cpp:723
~unit_type()
Definition: types.cpp:172
child_itors child_range(config_key_type key)
Definition: config.cpp:344
void adjust_profile(std::string &profile)
Definition: types.cpp:1483
const config * cfg_
Definition: types.hpp:320
void clear(const std::string &key)
Definition: general.cpp:186
t_string description_
Definition: types.hpp:334
void fill_variations()
Processes [variation] tags of ut_cfg, handling inheritance and child clearing.
Definition: types.cpp:1045
int experience_needed(bool with_acceleration=true) const
Definition: types.cpp:580
config possible_traits_
Definition: types.hpp:378
std::array< std::unique_ptr< unit_type >, 2 > gender_types_
Definition: types.hpp:356
void build_help_index(const movement_type_map &movement_types, const race_map &races, const config_array_view &traits)
Partially load data into an empty unit_type (build to HELP_INDEXED).
Definition: types.cpp:237
int resistance_against(const std::string &damage_name, bool attacker) const
Gets resistance while considering custom WML abilities.
Definition: types.cpp:776
const config & get_cfg() const
Definition: types.hpp:285
BUILD_STATUS
Records the status of the lazy building of unit types.
Definition: types.hpp:77
std::set< std::string > advancement_tree() const
Get the advancement tree.
Definition: types.cpp:648
const std::string & variation_id() const
The id of this variation; empty if it&#39;s a gender variation or a base unit.
Definition: types.hpp:150
t_string type_name_
Definition: types.hpp:333
variations_map variations_
Definition: types.hpp:358
const race_map & races() const
Definition: types.hpp:399
The basic "size" of the unit - flying, small land, large land, etc.
Definition: movetype.hpp:44
void build(BUILD_STATUS status, const movement_type_map &movement_types, const race_map &races, const config_array_view &traits) const
Performs a build of this to the indicated stage.
Definition: types.hpp:106
const unit_type_map & types() const
Definition: types.hpp:398
bool do_not_list() const
Definition: types.hpp:283
const std::vector< std::string > advances_from() const
A vector of unit_type ids that can advance to this unit_type.
Definition: types.cpp:655
int level_
Definition: types.hpp:338
A single unit type that the player may recruit.
Definition: types.hpp:45
const unit_race * race_
Never nullptr, but may point to the null race.
Definition: types.hpp:364
config & writable_cfg()
Definition: types.hpp:308
std::vector< t_string > combine_special_notes(const std::vector< t_string > direct, const config &abilities, const_attack_itors attacks, const movetype &mt)
Common logic for unit_type::special_notes() and unit::special_notes().
Definition: types.cpp:510
void build_full(const movement_type_map &movement_types, const race_map &races, const config_array_view &traits)
Load data into an empty unit_type (build to FULL).
Definition: types.cpp:194
std::string icon_
Definition: types.hpp:349
bool musthave_status(const std::string &status) const
Definition: types.cpp:675
const std::vector< unit_race::GENDER > & genders() const
The returned vector will not be empty, provided this has been built to the HELP_INDEXED status...
Definition: types.hpp:253
int cost() const
Definition: types.hpp:175
void fill_variations_and_gender()
Definition: types.cpp:1073
movement_type_map movement_types_
Definition: types.hpp:427
int vision() const
Definition: types.hpp:170
bool zoc_
Definition: types.hpp:368
bool hide_help() const
Definition: types.cpp:627
const movetype & movement_type() const
Definition: types.hpp:191
const std::vector< unit_animation > & animations() const
Definition: types.cpp:537
const t_string & type_name() const
The name of the unit in the current language setting.
Definition: types.hpp:141
std::vector< std::set< std::string > > hide_help_type_
Definition: types.hpp:433
std::vector< std::set< std::string > > hide_help_race_
Definition: types.hpp:434
const std::string & usage() const
Definition: types.hpp:178
std::vector< unit_animation > animations_
Definition: types.hpp:383
std::string small_profile_
Definition: types.hpp:350
std::string ellipse() const
Definition: types.hpp:184
std::unique_ptr< config > built_cfg_
Definition: types.hpp:322
std::string undead_variation_
Definition: types.hpp:346
void remove_scenario_fixes()
Definition: types.cpp:1426
int movement_
Definition: types.hpp:340
movetype movement_type_
Definition: types.hpp:376
const std::vector< ability_metadata > & abilities_metadata() const
Definition: types.hpp:221
std::string race_id() const
Returns the ID of this type&#39;s race without the need to build the type.
Definition: types.hpp:276
const std::string & id() const
The id for this unit_type.
Definition: types.hpp:144
std::map< std::string, movetype > movement_type_map
Definition: types.hpp:36
double xp_bar_scaling_
Definition: types.hpp:337
double xp_bar_scaling() const
Definition: types.hpp:166
boost::iterator_range< const_child_iterator > const_child_itors
Definition: config.hpp:206
int cost_
Definition: types.hpp:344
const std::string & undead_variation() const
Info on the type of unit that the unit reanimates as.
Definition: types.hpp:136
const std::string log_id() const
A variant on id() that is more descriptive, for use with message logging.
Definition: types.hpp:146
const game_config_view & units_cfg() const
Definition: types.hpp:436
config::const_child_itors modification_advancements() const
Returns two iterators pointing to a range of AMLA configs.
Definition: types.hpp:123
std::vector< t_string > special_notes_
Definition: types.hpp:335
bool has_zoc() const
Definition: types.hpp:230
unsigned int num_traits_
Definition: types.hpp:354
int recall_cost() const
Definition: types.hpp:168
game_config_view units_cfg_
Definition: types.hpp:437
std::vector< std::string > variations() const
Definition: types.cpp:748
unit_type_map types_
Definition: types.hpp:426
std::vector< std::string > get_ability_list() const
Definition: types.cpp:607
friend class unit_type_data
Definition: types.hpp:321
void apply_scenario_fix(const config &cfg)
Definition: types.cpp:1374
bool show_variations_in_help() const
Whether the unit type has at least one help-visible variation.
Definition: types.cpp:765
const config & abilities_cfg() const
Definition: types.hpp:238
std::vector< std::string > advances_to_
Definition: types.hpp:370
std::string usage_
Definition: types.hpp:345
std::string halo() const
Definition: types.hpp:183
bool has_ability_by_id(const std::string &ability) const
Definition: types.cpp:594
double hp_bar_scaling_
Definition: types.hpp:337
const std::string & icon() const
Definition: types.hpp:180
bool hide_help_all_
True if [hide_help] contains a &#39;all=yes&#39; at its root.
Definition: types.hpp:431
int level() const
Definition: types.hpp:167
std::string base_unit_id_
from [base_unit]
Definition: types.hpp:332
bool has_gender_variation(const unit_race::GENDER gender) const
Definition: types.hpp:254
const std::string & small_profile() const
Definition: types.hpp:181
int hitpoints() const
Definition: types.hpp:164
int jamming() const
Definition: types.hpp:173
const std::vector< ability_metadata > & adv_abilities_metadata() const
Some extra abilities that may be gained through AMLA advancements.
Definition: types.hpp:224
std::vector< t_string > special_notes() const
Returns all notes that should be displayed in the help page for this type, including those found in a...
Definition: types.cpp:496
int movement() const
Definition: types.hpp:169
std::string id_
Definition: types.hpp:326
config::const_child_itors possible_traits() const
Definition: types.hpp:235
const std::string & image() const
Definition: types.hpp:179
std::vector< ability_metadata > abilities_
Definition: types.hpp:366
bool resistance_filter_matches(const config &cfg, bool attacker, const std::string &damage_name, int res) const
Identical to unit::resistance_filter_matches.
Definition: types.cpp:807
int vision_
Definition: types.hpp:341
unsigned int num_traits() const
Definition: types.hpp:138
BUILD_STATUS build_status_
Definition: types.hpp:385
const unit_type & get_variation(const std::string &id) const
Definition: types.cpp:477
std::vector< std::reference_wrapper< const config > > config_array_view
int max_attacks_
Definition: types.hpp:343
int max_attacks() const
Definition: types.hpp:174
bool hide_help_
Definition: types.hpp:368
std::vector< ability_metadata > adv_abilities_
Definition: types.hpp:366
const t_string & variation_name() const
Definition: types.hpp:177
const variations_map & variation_types() const
Definition: types.hpp:260
const unit_race * race() const
Never returns nullptr, but may point to the null race.
Definition: types.hpp:281
const unit_type & get_gender_unit_type(std::string gender) const
Returns a gendered variant of this unit_type.
Definition: types.cpp:456
static void check_id(std::string &id)
Validate the id argument.
Definition: types.cpp:1455
double hp_bar_scaling() const
Definition: types.hpp:165
std::vector< t_string > direct_special_notes() const
Returns only the notes defined by [unit_type][special_note] tags, excluding any that would be found f...
Definition: types.hpp:158
unit_type & operator=(const unit_type &o)=delete
unit_type_data unit_types
Definition: types.cpp:1481
std::unique_ptr< unit_type > create_sub_type(const config &var_cfg, bool default_inherit)
Handles inheritance for configs of [male], [female], and [variation].
Definition: types.cpp:1028
const config & child_or_empty(config_key_type key) const
Returns the first child with the given key, or an empty config if there is none.
Definition: config.cpp:465
const_attack_itors attacks() const
Definition: types.cpp:546
std::map< std::string, unit_race > race_map
Definition: race.hpp:95
bool can_advance() const
Definition: types.hpp:226
boost::iterator_range< boost::indirect_iterator< attack_list::const_iterator > > const_attack_itors
t_string unit_description() const
Definition: types.cpp:487
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
static std::string alignment_description(ALIGNMENT align, unit_race::GENDER gender=unit_race::MALE)
attack_list attacks_cache_
Definition: types.hpp:324
bool has_random_traits() const
Definition: types.cpp:728
ALIGNMENT alignment() const
Definition: types.hpp:197
bool has_variation(const std::string &variation_id) const
Definition: types.cpp:760
Defines the MAKE_ENUM macro.
std::string image_
Definition: types.hpp:348
race_map races_
Definition: types.hpp:428
config::const_child_itors advancements() const
Definition: types.hpp:241
std::vector< unit_race::GENDER > genders_
Definition: types.hpp:380
const std::string & default_variation() const
Definition: types.hpp:176
std::map< std::string, unit_type > variations_map
Definition: types.hpp:97
void build_created()
Load the most needed data into an empty unit_type (build to CREATE).
Definition: types.cpp:378