The Battle for Wesnoth  1.15.2+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 "game_errors.hpp"
24 
25 #include <array>
26 #include <map>
27 #include <set>
28 #include <string>
29 #include <vector>
30 
31 class unit_ability_list;
33 
34 
35 typedef std::map<std::string, movetype> movement_type_map;
36 
37 
38 /**
39  * A single unit type that the player may recruit.
40  * Individual units are defined by the unit class.
41  */
42 class unit_type
43 {
44 public:
45  class error : public game::game_error
46  {
47  public:
48  error(const std::string& msg)
49  : game::game_error(msg)
50  {
51  }
52  };
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  unit_type(const unit_type& o);
61 
62  ~unit_type();
63 
64  /// Records the status of the lazy building of unit types.
65  /// These are in order of increasing levels of being built.
66  /// HELP_INDEX is already defined in a windows header under some conditions.
68 
69  /**
70  * Validate the id argument.
71  * Replaces invalid characters in the reference with underscores.
72  * @param id The proposed id for a unit_type.
73  * @throw error if id starts with a space.
74  */
75  static void check_id(std::string& id);
76 
77 private: // These will be called by build().
78  /// Load data into an empty unit_type (build to FULL).
79  void build_full(const movement_type_map &movement_types,
80  const race_map &races, const config::const_child_itors &traits);
81  /// Partially load data into an empty unit_type (build to HELP_INDEXED).
82  void build_help_index(const movement_type_map &movement_types,
83  const race_map &races, const config::const_child_itors &traits);
84  /// Load the most needed data into an empty unit_type (build to CREATE).
85  void build_created();
86 
87  typedef std::map<std::string,unit_type> variations_map;
88 public:
89  /// Performs a build of this to the indicated stage.
90  void build(BUILD_STATUS status, const movement_type_map &movement_types,
91  const race_map &races, const config::const_child_itors &traits);
92  /// Performs a build of this to the indicated stage.
93  /// (This does not logically change the unit type, so allow const access.)
94  void build(BUILD_STATUS status, const movement_type_map &movement_types,
95  const race_map &races, const config::const_child_itors &traits) const
96  { const_cast<unit_type *>(this)->build(status, movement_types, races, traits); }
97 
98 
99  /**
100  * Adds an additional advancement path to a unit type.
101  * This is used to implement the [advancefrom] tag.
102  */
103  void add_advancement(const unit_type &advance_to,int experience);
104 
105  /** Get the advancement tree
106  * @return A set of ids of all unit_type objects that this unit_type can
107  * directly or indirectly advance to.
108  */
109  std::set<std::string> advancement_tree() const;
110 
111  /// A vector of unit_type ids that this unit_type can advance to.
112  const std::vector<std::string>& advances_to() const { return advances_to_; }
113  /// A vector of unit_type ids that can advance to this unit_type.
114  const std::vector<std::string> advances_from() const;
115 
116  /// Returns two iterators pointing to a range of AMLA configs.
118  { return cfg_.child_range("advancement"); }
119 
120  /**
121  * Returns a gendered variant of this unit_type.
122  * @param gender "male" or "female".
123  */
124  const unit_type& get_gender_unit_type(std::string gender) const;
125  /// Returns a gendered variant of this unit_type based on the given parameter.
126  const unit_type& get_gender_unit_type(unit_race::GENDER gender) const;
127 
128  const unit_type& get_variation(const std::string& id) const;
129  /** Info on the type of unit that the unit reanimates as. */
130  const std::string& undead_variation() const { return undead_variation_; }
131 
132  unsigned int num_traits() const { return num_traits_; }
133 
134  /** The name of the unit in the current language setting. */
135  const t_string& type_name() const { return type_name_; }
136 
137  /// The id for this unit_type.
138  const std::string& id() const { return id_; }
139  /// A variant on id() that is more descriptive, for use with message logging.
140  const std::string log_id() const { return id_ + debug_id_; }
141  /// The id of the original type from which this (variation) descended.
142  const std::string& base_id() const { return base_id_; }
143  /// The id of this variation; empty if it's a gender variation or a base unit.
144  const std::string& variation_id() const { return variation_id_; }
145  // NOTE: this used to be a const object reference, but it messed up with the
146  // translation engine upon changing the language in the same session.
147  t_string unit_description() const;
148  bool has_special_notes() const;
149  const std::vector<t_string>& special_notes() const;
150  int hitpoints() const { return hitpoints_; }
151  double hp_bar_scaling() const { return hp_bar_scaling_; }
152  double xp_bar_scaling() const { return xp_bar_scaling_; }
153  int level() const { return level_; }
154  int recall_cost() const { return recall_cost_;}
155  int movement() const { return movement_; }
156  int vision() const { return vision_ < 0 ? movement() : vision_; }
157  /// If @a base_value is set to true, do not fall back to movement().
158  int vision(bool base_value) const { return base_value ? vision_ : vision(); }
159  int jamming() const {return jamming_; }
160  int max_attacks() const { return max_attacks_; }
161  int cost() const { return cost_; }
162  const std::string& default_variation() const { return default_variation_; }
163  const t_string& variation_name() const { return variation_name_; }
164  const std::string& usage() const { return usage_; }
165  const std::string& image() const { return image_; }
166  const std::string& icon() const { return icon_; }
167  const std::string &small_profile() const { return small_profile_; }
168  const std::string &big_profile() const { return profile_; }
169  std::string halo() const { return cfg_["halo"]; }
170  std::string ellipse() const { return cfg_["ellipse"]; }
171  bool generate_name() const { return cfg_["generate_name"].to_bool(true); }
172  const std::vector<unit_animation>& animations() const;
173 
174  const std::string& flag_rgb() const;
175 
176  const_attack_itors attacks() const;
177  const movetype & movement_type() const { return movement_type_; }
178 
179  int experience_needed(bool with_acceleration=true) const;
180 
181  MAKE_ENUM (ALIGNMENT,
182  (LAWFUL, N_("lawful"))
183  (NEUTRAL, N_("neutral"))
184  (CHAOTIC, N_("chaotic"))
185  (LIMINAL, N_("liminal"))
186  )
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 cfg_.child_or_empty("abilities"); }
231 
233  { return cfg_.child_range("advancement"); }
234 
236  { return cfg_.child_range("event"); }
237 
238  bool has_random_traits() const;
239 
240  /// The returned vector will not be empty, provided this has been built
241  /// to the HELP_INDEXED status.
242  const std::vector<unit_race::GENDER>& genders() const { return genders_; }
243  bool has_gender_variation(const unit_race::GENDER gender) const
244  {
245  return std::find(genders_.begin(), genders_.end(), gender) != genders_.end();
246  }
247 
248  std::vector<std::string> variations() const;
249  const variations_map& variation_types() const {return variations_; }
250 
251  /**
252  * @param variation_id The id of the variation we search for.
253  * @return Whether one of the type's variations' (or the
254  * siblings' if the unit_type is a variation
255  * itself) id matches @a variation_id.
256  */
257  bool has_variation(const std::string& variation_id) const;
258 
259  /**
260  * Whether the unit type has at least one help-visible variation.
261  */
262  bool show_variations_in_help() const;
263 
264  /// Returns the ID of this type's race without the need to build the type.
265  std::string race_id() const { return cfg_["race"]; } //race_->id(); }
266  /// Never returns nullptr, but may point to the null race.
267  /// Requires building to the HELP_INDEXED status to get the correct race.
268  const unit_race* race() const { return race_; }
269  bool hide_help() const;
270  bool do_not_list() const { return do_not_list_; }
271 
272  const config &get_cfg() const { return cfg_; }
273  /// Returns a trimmed config suitable for use with units.
274  const config & get_cfg_for_units() const
275  { return built_unit_cfg_ ? unit_cfg_ : build_unit_cfg(); }
276 
277  /// Gets resistance while considering custom WML abilities.
278  /// Attention: Filters in resistance-abilities will be ignored.
279  int resistance_against(const std::string& damage_name, bool attacker) const;
280 
281  void apply_scenario_fix(const config& cfg);
282  void remove_scenario_fixes();
283 private:
284  /// Generates (and returns) a trimmed config suitable for use with units.
285  const config & build_unit_cfg() const;
286 
287  /// Identical to unit::resistance_filter_matches.
288  bool resistance_filter_matches(const config& cfg,bool attacker,const std::string& damage_name, int res) const;
289 
290 private:
291  void operator=(const unit_type& o);
292 
293  const config &cfg_;
294  mutable config unit_cfg_; /// Generated as needed via get_cfg_for_units().
295  mutable bool built_unit_cfg_;
297 
298  std::string id_;
299  std::string debug_id_; /// A suffix for id_, used when logging messages.
300  std::string base_id_; /// The id of the top ancestor of this unit_type.
303  std::vector<t_string> special_notes_;
306  int level_;
309  int vision_;
310  int jamming_;
312  int cost_;
313  std::string usage_;
314  std::string undead_variation_;
315 
316  std::string image_;
317  std::string icon_;
318  std::string small_profile_;
319  std::string profile_;
320  std::string flag_rgb_;
321 
322  unsigned int num_traits_;
323 
324  std::array<std::unique_ptr<unit_type>, 2> gender_types_;
325 
326  variations_map variations_;
327  std::string default_variation_;
328  std::string variation_id_;
330 
331  const unit_race* race_; /// Never nullptr, but may point to the null race.
332 
333  std::vector<ability_metadata> abilities_, adv_abilities_;
334 
336 
337  std::vector<std::string> advances_to_;
340 
341 
342  ALIGNMENT alignment_;
343 
345 
347 
348  std::vector<unit_race::GENDER> genders_;
349 
350  // animations are loaded only after the first animations() call
351  mutable std::vector<unit_animation> animations_;
352 
354 };
355 
357 {
358 public:
359  unit_type_data(const unit_type_data&) = delete;
360  unit_type_data& operator=(const unit_type_data&) = delete;
361 
362  unit_type_data();
363 
364  typedef std::map<std::string,unit_type> unit_type_map;
365 
366  const unit_type_map &types() const { return types_; }
367  const race_map &races() const { return races_; }
368  const config::const_child_itors traits() const { return unit_cfg_->child_range("trait"); }
369  void set_config(config &cfg);
370 
371  /// Finds a unit_type by its id() and makes sure it is built to the specified level.
372  const unit_type *find(const std::string &key, unit_type::BUILD_STATUS status = unit_type::FULL) const;
373  void check_types(const std::vector<std::string>& types) const;
374  const unit_race *find_race(const std::string &) const;
375 
376  /// Makes sure the all unit_types are built to the specified level.
377  void build_all(unit_type::BUILD_STATUS status);
378  /// Makes sure the provided unit_type is built to the specified level.
379  void build_unit_type(const unit_type & ut, unit_type::BUILD_STATUS status) const
380  { ut.build(status, movement_types_, races_, unit_cfg_->child_range("trait")); }
381 
382  /** Checks if the [hide_help] tag contains these IDs. */
383  bool hide_help(const std::string &type_id, const std::string &race_id) const;
384 
385  void apply_scenario_fix(const config& cfg);
386  void remove_scenario_fixes();
387 private:
388  /** Parses the [hide_help] tag. */
389  void read_hide_help(const config &cfg);
390 
391  void clear();
392 
393  void add_advancefrom(const config& unit_cfg) const;
394  void add_advancement(unit_type& to_unit) const;
395 
396  mutable unit_type_map types_;
399 
400  /** True if [hide_help] contains a 'all=yes' at its root. */
402  // vectors containing the [hide_help] and its sub-tags [not]
403  std::vector< std::set<std::string>> hide_help_type_;
404  std::vector< std::set<std::string>> hide_help_race_;
405 
408 };
409 
411 
412 void adjust_profile(std::string& profile);
413 
415  unit_experience_accelerator(int modifier);
417  static int get_acceleration();
418 private:
420 };
int jamming_
Definition: types.hpp:310
std::vector< attack_ptr > attack_list
const std::string & base_id() const
The id of the original type from which this (variation) descended.
Definition: types.hpp:142
int experience_needed_
Definition: types.hpp:338
bool do_not_list_
Definition: types.hpp:335
unit_type::BUILD_STATUS build_status_
Definition: types.hpp:407
std::map< std::string, unit_type > unit_type_map
Definition: types.hpp:364
int vision(bool base_value) const
If base_value is set to true, do not fall back to movement().
Definition: types.hpp:158
std::string default_variation_
Definition: types.hpp:327
error(const std::string &msg)
Definition: types.hpp:48
std::string flag_rgb_
Definition: types.hpp:320
bool generate_name() const
Definition: types.hpp:171
ALIGNMENT alignment_
Definition: types.hpp:342
t_string variation_name_
Definition: types.hpp:329
std::string profile_
Definition: types.hpp:319
config::const_child_itors events() const
Definition: types.hpp:235
const std::vector< t_string > & special_notes() const
Definition: types.cpp:496
const std::string & big_profile() const
Definition: types.hpp:168
std::string debug_id_
Definition: types.hpp:299
int hitpoints_
Definition: types.hpp:304
const std::vector< std::string > & advances_to() const
A vector of unit_type ids that this unit_type can advance to.
Definition: types.hpp:112
int recall_cost_
Definition: types.hpp:307
std::string base_id_
A suffix for id_, used when logging messages.
Definition: types.hpp:300
const config & build_unit_cfg() const
Generates (and returns) a trimmed config suitable for use with units.
Definition: types.cpp:803
std::string variation_id_
Definition: types.hpp:328
const std::string & flag_rgb() const
Definition: types.cpp:747
~unit_type()
Definition: types.cpp:154
child_itors child_range(config_key_type key)
Definition: config.cpp:362
bool has_special_notes() const
Definition: types.cpp:491
void adjust_profile(std::string &profile)
Definition: types.cpp:1531
void clear(const std::string &key)
Definition: general.cpp:205
t_string description_
Definition: types.hpp:302
int experience_needed(bool with_acceleration=true) const
Definition: types.cpp:543
config possible_traits_
Definition: types.hpp:346
std::array< std::unique_ptr< unit_type >, 2 > gender_types_
Definition: types.hpp:324
int resistance_against(const std::string &damage_name, bool attacker) const
Gets resistance while considering custom WML abilities.
Definition: types.cpp:847
const config & get_cfg() const
Definition: types.hpp:272
BUILD_STATUS
Records the status of the lazy building of unit types.
Definition: types.hpp:67
std::set< std::string > advancement_tree() const
Get the advancement tree.
Definition: types.cpp:672
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
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:144
t_string type_name_
The id of the top ancestor of this unit_type.
Definition: types.hpp:301
bool built_unit_cfg_
Generated as needed via get_cfg_for_units().
Definition: types.hpp:295
variations_map variations_
Definition: types.hpp:326
const race_map & races() const
Definition: types.hpp:367
const config & cfg_
Definition: types.hpp:293
The basic "size" of the unit - flying, small land, large land, etc.
Definition: movetype.hpp:41
void operator=(const unit_type &o)
const unit_type_map & types() const
Definition: types.hpp:366
void build_help_index(const movement_type_map &movement_types, const race_map &races, const config::const_child_itors &traits)
Partially load data into an empty unit_type (build to HELP_INDEXED).
Definition: types.cpp:219
bool do_not_list() const
Definition: types.hpp:270
const std::vector< std::string > advances_from() const
A vector of unit_type ids that can advance to this unit_type.
Definition: types.cpp:679
int level_
Definition: types.hpp:306
A single unit type that the player may recruit.
Definition: types.hpp:42
const unit_race * race_
Definition: types.hpp:331
void build_unit_type(const unit_type &ut, unit_type::BUILD_STATUS status) const
Makes sure the provided unit_type is built to the specified level.
Definition: types.hpp:379
bool in_advancefrom_
Definition: types.hpp:339
std::string icon_
Definition: types.hpp:317
bool musthave_status(const std::string &status) const
Definition: types.cpp:699
const config & get_cfg_for_units() const
Returns a trimmed config suitable for use with units.
Definition: types.hpp:274
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:242
int cost() const
Definition: types.hpp:161
movement_type_map movement_types_
Definition: types.hpp:397
int vision() const
Definition: types.hpp:156
bool zoc_
Definition: types.hpp:335
bool hide_help() const
Definition: types.cpp:590
const movetype & movement_type() const
Definition: types.hpp:177
const std::vector< unit_animation > & animations() const
Definition: types.cpp:500
const t_string & type_name() const
The name of the unit in the current language setting.
Definition: types.hpp:135
std::vector< std::set< std::string > > hide_help_type_
Definition: types.hpp:403
void build(BUILD_STATUS status, const movement_type_map &movement_types, const race_map &races, const config::const_child_itors &traits) const
Performs a build of this to the indicated stage.
Definition: types.hpp:94
std::vector< std::set< std::string > > hide_help_race_
Definition: types.hpp:404
const std::string & usage() const
Definition: types.hpp:164
std::vector< unit_animation > animations_
Definition: types.hpp:351
std::string small_profile_
Definition: types.hpp:318
std::string ellipse() const
Definition: types.hpp:170
MAKE_ENUM(ALIGNMENT,(LAWFUL, N_("lawful"))(NEUTRAL, N_("neutral"))(CHAOTIC, N_("chaotic"))(LIMINAL, N_("liminal"))) ALIGNMENT alignment() const
Definition: types.hpp:181
std::string undead_variation_
Definition: types.hpp:314
void add_advancement(const unit_type &advance_to, int experience)
Adds an additional advancement path to a unit type.
Definition: types.cpp:595
void remove_scenario_fixes()
Definition: types.cpp:1474
int movement_
Definition: types.hpp:308
movetype movement_type_
Definition: types.hpp:344
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:265
const std::string & id() const
The id for this unit_type.
Definition: types.hpp:138
std::map< std::string, movetype > movement_type_map
Definition: types.hpp:32
Error used for any general game error, e.g.
Definition: game_errors.hpp:46
double xp_bar_scaling_
Definition: types.hpp:305
const config::const_child_itors traits() const
Definition: types.hpp:368
double xp_bar_scaling() const
Definition: types.hpp:152
boost::iterator_range< const_child_iterator > const_child_itors
Definition: config.hpp:210
int cost_
Definition: types.hpp:312
void build(BUILD_STATUS status, const movement_type_map &movement_types, const race_map &races, const config::const_child_itors &traits)
Performs a build of this to the indicated stage.
Definition: types.cpp:416
const std::string & undead_variation() const
Info on the type of unit that the unit reanimates as.
Definition: types.hpp:130
const std::string log_id() const
A variant on id() that is more descriptive, for use with message logging.
Definition: types.hpp:140
config::const_child_itors modification_advancements() const
Returns two iterators pointing to a range of AMLA configs.
Definition: types.hpp:117
std::vector< t_string > special_notes_
Definition: types.hpp:303
bool has_zoc() const
Definition: types.hpp:221
unsigned int num_traits_
Definition: types.hpp:322
int recall_cost() const
Definition: types.hpp:154
std::vector< std::string > variations() const
Definition: types.cpp:772
void build_full(const movement_type_map &movement_types, const race_map &races, const config::const_child_itors &traits)
Load data into an empty unit_type (build to FULL).
Definition: types.cpp:176
unit_type_map types_
Definition: types.hpp:396
std::vector< std::string > get_ability_list() const
Definition: types.cpp:570
const config * unit_cfg_
Definition: types.hpp:406
void apply_scenario_fix(const config &cfg)
Definition: types.cpp:1422
bool show_variations_in_help() const
Whether the unit type has at least one help-visible variation.
Definition: types.cpp:789
const config & abilities_cfg() const
Definition: types.hpp:229
std::vector< std::string > advances_to_
Definition: types.hpp:337
std::string usage_
Definition: types.hpp:313
std::string halo() const
Definition: types.hpp:169
bool has_ability_by_id(const std::string &ability) const
Definition: types.cpp:557
double hp_bar_scaling_
Definition: types.hpp:305
const std::string & icon() const
Definition: types.hpp:166
bool hide_help_all_
True if [hide_help] contains a &#39;all=yes&#39; at its root.
Definition: types.hpp:401
int level() const
Definition: types.hpp:153
#define N_(String)
Definition: gettext.hpp:99
bool has_gender_variation(const unit_race::GENDER gender) const
Definition: types.hpp:243
const std::string & small_profile() const
Definition: types.hpp:167
int hitpoints() const
Definition: types.hpp:150
int jamming() const
Definition: types.hpp:159
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:155
std::string id_
Definition: types.hpp:298
config::const_child_itors possible_traits() const
Definition: types.hpp:226
const std::string & image() const
Definition: types.hpp:165
std::vector< ability_metadata > abilities_
Never nullptr, but may point to the null race.
Definition: types.hpp:333
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:878
int vision_
Definition: types.hpp:309
unsigned int num_traits() const
Definition: types.hpp:132
BUILD_STATUS build_status_
Definition: types.hpp:353
const unit_type & get_variation(const std::string &id) const
Definition: types.cpp:472
int max_attacks_
Definition: types.hpp:311
bool find(E event, F functor)
Tests whether an event handler is available.
int max_attacks() const
Definition: types.hpp:160
unit_type(const config &cfg, const std::string &parent_id="")
Creates a unit type for the given config, but delays its build till later.
Definition: types.cpp:103
bool hide_help_
Definition: types.hpp:335
std::vector< ability_metadata > adv_abilities_
Definition: types.hpp:333
const t_string & variation_name() const
Definition: types.hpp:163
const variations_map & variation_types() const
Definition: types.hpp:249
const unit_race * race() const
Never returns nullptr, but may point to the null race.
Definition: types.hpp:268
const unit_type & get_gender_unit_type(std::string gender) const
Returns a gendered variant of this unit_type.
Definition: types.cpp:451
static void check_id(std::string &id)
Validate the id argument.
Definition: types.cpp:1503
double hp_bar_scaling() const
Definition: types.hpp:151
config unit_cfg_
Definition: types.hpp:294
unit_type_data unit_types
Definition: types.cpp:1529
game_error(const std::string &msg)
Definition: game_errors.hpp:47
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:453
const_attack_itors attacks() const
Definition: types.cpp:509
std::map< std::string, unit_race > race_map
Definition: race.hpp:91
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:482
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
static std::string alignment_description(ALIGNMENT align, unit_race::GENDER gender=unit_race::MALE)
attack_list attacks_cache_
Definition: types.hpp:296
bool has_random_traits() const
Definition: types.cpp:752
bool has_variation(const std::string &variation_id) const
Definition: types.cpp:784
Defines the MAKE_ENUM macro.
std::string image_
Definition: types.hpp:316
race_map races_
Definition: types.hpp:398
config::const_child_itors advancements() const
Definition: types.hpp:232
std::vector< unit_race::GENDER > genders_
Definition: types.hpp:348
const std::string & default_variation() const
Definition: types.hpp:162
std::map< std::string, unit_type > variations_map
Definition: types.hpp:87
void build_created()
Load the most needed data into an empty unit_type (build to CREATE).
Definition: types.cpp:371