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