The Battle for Wesnoth  1.19.18+dev
types.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2025
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 "movetype.hpp"
21 #include "units/race.hpp"
22 #include "units/attack_type.hpp"
23 #include "units/type_error.hpp"
24 #include "game_config_view.hpp"
25 
26 #include <memory>
27 #include <array>
28 #include <map>
29 #include <set>
30 #include <string>
31 #include <vector>
32 
33 class unit_animation;
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 private:
45  struct default_ctor_t {};
46  unit_type(default_ctor_t, const config& cfg, const std::string& parent_id);
47 
48 public:
50  /**
51  * Creates a unit type for the given config, but delays its build
52  * till later.
53  * @note @a cfg is not copied, so it has to point to some permanent
54  * storage, that is, a child of unit_type_data::unit_cfg.
55  */
56  explicit unit_type(const config& cfg, const std::string& parent_id="");
57  /**
58  * Creates a unit type for the given config, but delays its build
59  * till later.
60  * @note @a cfg is copied
61  */
62  explicit unit_type(config&& cfg, const std::string& parent_id="");
63 
64  unit_type(const unit_type&) = delete;
65  unit_type& operator=(const unit_type&) = delete;
66 
67  unit_type(unit_type&&) noexcept = default;
68  unit_type& operator=(unit_type&&) noexcept = 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  const ability_vector& abilities() const { return abilities_; }
118  /** A vector of unit_type ids that this unit_type can advance to. */
119  const std::vector<std::string>& advances_to() const { return advances_to_; }
120  /** A vector of unit_type ids that can advance to this unit_type. */
121  const std::vector<std::string> advances_from() const;
122 
123  /** Returns two iterators pointing to a range of AMLA configs. */
125  { return advancements_; }
126 
127  /**
128  * Returns a gendered variant of this unit_type.
129  * @param gender "male" or "female".
130  */
131  const unit_type& get_gender_unit_type(const std::string& gender) const;
132  /** Returns a gendered variant of this unit_type based on the given parameter. */
133  const unit_type& get_gender_unit_type(unit_race::GENDER gender) const;
134 
135  const unit_type& get_variation(const std::string& id) const;
136  /** Info on the type of unit that the unit reanimates as. */
137  const std::string& undead_variation() const { return undead_variation_; }
138 
139  unsigned int num_traits() const { return num_traits_; }
140 
141  /** The name of the unit in the current language setting. */
142  const t_string& type_name() const { return type_name_; }
143 
144  /** The id for this unit_type. */
145  const std::string& id() const { return id_; }
146  /** A variant on id() that is more descriptive, for use with message logging. */
147  const std::string log_id() const { return id_ + debug_id_; }
148  /** The id of the original type from which this (variation) descended. */
149  const std::string& parent_id() const { return parent_id_; }
150  /** The id of this variation; empty if it's a gender variation or a base unit. */
151  const std::string& variation_id() const { return variation_id_; }
152  // NOTE: this used to be a const object reference, but it messed up with the
153  // translation engine upon changing the language in the same session.
154  t_string unit_description() const;
155  /**
156  * Returns only the notes defined by [unit_type][special_note] tags, excluding
157  * any that would be found from abilities, attacks, etc.
158  */
159  std::vector<t_string> direct_special_notes() const { return special_notes_; }
160  /**
161  * Returns all notes that should be displayed in the help page for this type,
162  * including those found in abilities and attacks.
163  */
164  std::vector<t_string> special_notes() const;
165  int hitpoints() const { return hitpoints_; }
166  double hp_bar_scaling() const { return hp_bar_scaling_; }
167  double xp_bar_scaling() const { return xp_bar_scaling_; }
168  int level() const { return level_; }
169  int recall_cost() const { return recall_cost_;}
170  int movement() const { return movement_; }
171  int vision() const { return vision_ < 0 ? movement() : vision_; }
172  /** If @a base_value is set to true, do not fall back to movement(). */
173  int vision(bool base_value) const { return base_value ? vision_ : vision(); }
174  int jamming() const {return jamming_; }
175  int max_attacks() const { return max_attacks_; }
176  int cost() const { return cost_; }
177  const std::string& default_variation() const { return default_variation_; }
178  const t_string& variation_name() const { return variation_name_; }
179  const std::string& usage() const { return usage_; }
180  const std::string& image() const { return image_; }
181  const std::string& icon() const { return icon_; }
182  const std::string& small_profile() const { return small_profile_; }
183  const std::string& big_profile() const { return profile_; }
184  std::string halo() const { return get_cfg()["halo"]; }
185  std::string ellipse() const { return get_cfg()["ellipse"]; }
186  bool generate_name() const { return get_cfg()["generate_name"].to_bool(true); }
187  const std::vector<unit_animation>& animations() const;
188 
189  const std::string& flag_rgb() const;
190 
191  const_attack_itors attacks() const;
192  const std::string movement_type_id() const {return movement_type_id_; }
193  const movetype& movement_type() const { return movement_type_; }
194 
195  int experience_needed(bool with_acceleration=true) const;
196 
199 
201  {
202  //TODO:most of the member of this class seem to be unused.
203  explicit ability_metadata(const config& cfg);
204 
205  std::string id;
206 
207  std::string help_topic_id;
208 
211 
214 
217 
222  };
223 
224  const std::vector<ability_metadata>& abilities_metadata() const { return abilities_infos_; }
225 
226  /** Some extra abilities that may be gained through AMLA advancements. */
227  const std::vector<ability_metadata>& adv_abilities_metadata() const { return adv_abilities_infos_; }
228 
229  bool can_advance() const { return !advances_to_.empty(); }
230 
231  bool musthave_status(const std::string& status) const;
232 
233  bool has_zoc() const { return zoc_; }
234 
235  bool has_ability_by_id(const std::string& ability) const;
236  std::vector<std::string> get_ability_id_list() const;
237 
239  { return possible_traits_.child_range("trait"); }
240 
241  config abilities_cfg() const;
242 
244  { return advancements_; }
245 
247  { return get_cfg().child_range("event"); }
248 
249  bool has_random_traits() const;
250 
251  /**
252  * The returned vector will not be empty, provided this has been built
253  * to the HELP_INDEXED status.
254  */
255  const std::vector<unit_race::GENDER>& genders() const { return genders_; }
256  bool has_gender_variation(const unit_race::GENDER gender) const;
257 
258  std::vector<std::string> variations() const;
259  const variations_map& variation_types() const {return variations_; }
260 
261  /**
262  * @param variation_id The id of the variation we search for.
263  * @return Whether one of the type's variations' (or the
264  * siblings' if the unit_type is a variation
265  * itself) id matches @a variation_id.
266  */
267  bool has_variation(const std::string& variation_id) const;
268 
269  /**
270  * Whether the unit type has at least one help-visible variation.
271  */
272  bool show_variations_in_help() const;
273 
274  /** Returns the ID of this type's race without the need to build the type. */
275  std::string race_id() const { return get_cfg()["race"]; } //race_->id(); }
276  /**
277  * Never returns nullptr, but may point to the null race.
278  * Requires building to the HELP_INDEXED status to get the correct race.
279  */
280  const unit_race* race() const { return race_; }
281  bool hide_help() const;
282  bool do_not_list() const { return do_not_list_; }
283 
284  const config& get_cfg() const
285  {
286  if(built_cfg_) {
287  return *built_cfg_;
288  }
289  assert(cfg_);
290  return *cfg_;
291  }
292 
293  /**
294  * Gets resistance while considering custom WML abilities.
295  * Attention: Filters in resistance-abilities will be ignored.
296  */
297  int resistance_against(const std::string& damage_name, bool attacker) const;
298 
299  void apply_scenario_fix(const config& cfg);
300  void remove_scenario_fixes();
301 private:
302 
303  /** Identical to unit::resistance_filter_matches. */
304  bool resistance_filter_matches(const config& cfg,bool attacker, const std::string& damage_name, int res) const;
305 
306 private:
308  if(!built_cfg_) {
309  built_cfg_ = std::make_unique<config>(*cfg_);
310  }
311  return *built_cfg_;
312  }
313  void fill_variations();
315  std::unique_ptr<unit_type> create_sub_type(const config& var_cfg, bool default_inherit);
316 
317  const config* cfg_;
318  friend class unit_type_data;
319  mutable std::unique_ptr<config> built_cfg_;
321 
322  std::string id_;
323  /** A suffix for id_, used when logging messages. */
324  std::string debug_id_;
325  /** The id of the top ancestor of this unit_type. */
326  std::string parent_id_;
327  /** from [base_unit] */
328  std::string base_unit_id_;
331  std::vector<t_string> special_notes_;
334  int level_;
337  int vision_;
338  int jamming_;
340  int cost_;
341  std::string usage_;
342  std::string undead_variation_;
343 
344  std::string image_;
345  std::string icon_;
346  std::string small_profile_;
347  std::string profile_;
348  std::string flag_rgb_;
349 
350  unsigned int num_traits_;
351 
352  std::array<std::unique_ptr<unit_type>, 2> gender_types_;
353 
355  std::string default_variation_;
356  std::string variation_id_;
358 
359  /** Never nullptr, but may point to the null race. */
360  const unit_race* race_;
361 
362  std::vector<ability_metadata> abilities_infos_;
363  std::vector<ability_metadata> adv_abilities_infos_;
364 
366 
368 
369  std::vector<std::string> advances_to_;
372 
373 
375 
376  std::string movement_type_id_;
378 
380 
381  std::vector<unit_race::GENDER> genders_;
382 
383  // animations are loaded only after the first animations() call
384  mutable std::vector<unit_animation> animations_;
385 
387 };
388 
390 {
391 public:
392  unit_type_data(const unit_type_data&) = delete;
394 
395  unit_type_data();
396 
397  typedef std::map<std::string,unit_type> unit_type_map;
398 
399  const unit_type_map& types() const { return types_; }
400  const std::vector<const unit_type*> types_list() const {
401  std::vector<const unit_type*> types_list;
402  for(const auto& i : types()) {
403  // Make sure this unit type is built with the data we need.
405  types_list.push_back(&i.second);
406  }
407  return types_list;
408  }
409  const race_map& races() const { return races_; }
411  const std::map<std::string, config>& abilities() const { return abilities_registry_; }
412  const std::map<std::string, config>& specials() const { return specials_registry_; }
413  config_array_view traits() const { return units_cfg().child_range("trait"); }
414 
416  const config& base_cfg,
417  const std::string& registry_name,
418  const std::map<std::string, config>& registry
419  );
420 
421  void set_config(const game_config_view& cfg);
422 
423  /** Finds a unit_type by its id() and makes sure it is built to the specified level. */
424  const unit_type *find(const std::string& key, unit_type::BUILD_STATUS status = unit_type::FULL) const;
425  void check_types(const std::vector<std::string>& types) const;
426  const unit_race *find_race(const std::string&) const;
427 
428  /** Makes sure the all unit_types are built to the specified level. */
429  void build_all(unit_type::BUILD_STATUS status);
430  /** Makes sure the provided unit_type is built to the specified level. */
431  void build_unit_type(const unit_type& ut, unit_type::BUILD_STATUS status) const;
432 
433  /** Checks if the [hide_help] tag contains these IDs. */
434  bool hide_help(const std::string& type_id, const std::string& race_id) const;
435 
436  void apply_scenario_fix(const config& cfg);
437  void remove_scenario_fixes();
438 private:
439  /** Parses the [hide_help] tag. */
440  void read_hide_help(const config& cfg);
441 
442  void clear();
443 
444  void apply_base_unit(unit_type& type, std::vector<std::string>& base_tree);
445 
449 
450  std::map<std::string, config> abilities_registry_;
451  std::map<std::string, config> specials_registry_;
452 
453  /** True if [hide_help] contains a 'all=yes' at its root. */
455  // vectors containing the [hide_help] and its sub-tags [not]
456  std::vector<std::set<std::string>> hide_help_type_;
457  std::vector<std::set<std::string>> hide_help_race_;
458 
459  const game_config_view& units_cfg() const { return units_cfg_; }
462 };
463 
465 
466 void adjust_profile(std::string& profile);
467 
469  unit_experience_accelerator(int modifier);
471  static int get_acceleration();
472 private:
474 };
475 
476 /**
477  * Common logic for unit_type::special_notes() and unit::special_notes(). Adds
478  * any notes from the sources given as arguments, and filters out duplicates.
479  *
480  * @return the special notes for a unit or unit_type.
481  */
482 std::vector<t_string> combine_special_notes(
483  const std::vector<t_string>& direct,
484  const config& abilities,
485  const const_attack_itors& attacks,
486  const movetype& mt);
std::vector< ability_ptr > ability_vector
Definition: abilities.hpp:33
std::vector< attack_ptr > attack_list
boost::iterator_range< boost::indirect_iterator< attack_list::const_iterator > > const_attack_itors
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:157
child_itors child_range(std::string_view key)
Definition: config.cpp:268
boost::iterator_range< const_child_iterator > const_child_itors
Definition: config.hpp:281
A class grating read only view to a vector of config objects, viewed as one config with all children ...
config_array_view child_range(std::string_view key) const
The basic "size" of the unit - flying, small land, large land, etc.
Definition: movetype.hpp:44
@ MALE
Definition: race.hpp:28
static config add_registry_entries(const config &base_cfg, const std::string &registry_name, const std::map< std::string, config > &registry)
Definition: types.cpp:1061
std::map< std::string, config > specials_registry_
Definition: types.hpp:451
const std::map< std::string, config > & abilities() const
Definition: types.hpp:411
const movement_type_map & movement_types() const
Definition: types.hpp:410
void set_config(const game_config_view &cfg)
Resets all data based on the provided config.
Definition: types.cpp:1087
unit_type::BUILD_STATUS build_status_
Definition: types.hpp:461
std::map< std::string, unit_type > unit_type_map
Definition: types.hpp:397
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
Definition: types.cpp:1273
bool hide_help(const std::string &type_id, const std::string &race_id) const
Checks if the [hide_help] tag contains these IDs.
Definition: types.cpp:1362
void clear()
Definition: types.cpp:1303
std::map< std::string, config > abilities_registry_
Definition: types.hpp:450
void remove_scenario_fixes()
Definition: types.cpp:1477
const race_map & races() const
Definition: types.hpp:409
bool hide_help_all_
True if [hide_help] contains a 'all=yes' at its root.
Definition: types.hpp:454
race_map races_
Definition: types.hpp:448
void build_all(unit_type::BUILD_STATUS status)
Makes sure the all unit_types are built to the specified level.
Definition: types.cpp:1317
const std::vector< const unit_type * > types_list() const
Definition: types.hpp:400
void apply_base_unit(unit_type &type, std::vector< std::string > &base_tree)
Modifies the provided config by merging all base units into it.
Definition: types.cpp:957
const std::map< std::string, config > & specials() const
Definition: types.hpp:412
unit_type_map types_
Definition: types.hpp:446
const unit_race * find_race(const std::string &) const
Definition: types.cpp:1379
void check_types(const std::vector< std::string > &types) const
Definition: types.cpp:1294
movement_type_map movement_types_
Definition: types.hpp:447
game_config_view units_cfg_
Definition: types.hpp:460
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.cpp:1265
const game_config_view & units_cfg() const
Definition: types.hpp:459
const unit_type_map & types() const
Definition: types.hpp:399
void read_hide_help(const config &cfg)
Parses the [hide_help] tag.
Definition: types.cpp:1333
unit_type_data & operator=(const unit_type_data &)=delete
std::vector< std::set< std::string > > hide_help_type_
Definition: types.hpp:456
std::vector< std::set< std::string > > hide_help_race_
Definition: types.hpp:457
void apply_scenario_fix(const config &cfg)
Definition: types.cpp:1442
unit_type_data(const unit_type_data &)=delete
config_array_view traits() const
Definition: types.hpp:413
A single unit type that the player may recruit.
Definition: types.hpp:43
std::string default_variation_
Definition: types.hpp:355
t_string description_
Definition: types.hpp:330
std::string image_
Definition: types.hpp:344
bool can_advance() const
Definition: types.hpp:229
std::vector< unit_animation > animations_
Definition: types.hpp:384
const std::vector< std::string > advances_from() const
A vector of unit_type ids that can advance to this unit_type.
Definition: types.cpp:610
unit_alignments::type alignment_
Definition: types.hpp:374
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:159
int jamming_
Definition: types.hpp:338
std::string race_id() const
Returns the ID of this type's race without the need to build the type.
Definition: types.hpp:275
int recall_cost_
Definition: types.hpp:335
const std::string & parent_id() const
The id of the original type from which this (variation) descended.
Definition: types.hpp:149
int cost_
Definition: types.hpp:340
config::const_child_itors advancements_
Definition: types.hpp:370
void fill_variations()
Processes [variation] tags of ut_cfg, handling inheritance and child clearing.
Definition: types.cpp:1013
static std::string alignment_description(unit_alignments::type align, unit_race::GENDER gender=unit_race::MALE)
Implementation detail of unit_type::alignment_description.
Definition: types.cpp:799
std::vector< t_string > special_notes_
Definition: types.hpp:331
const ability_vector & abilities() const
Definition: types.hpp:117
const unit_type & get_gender_unit_type(const std::string &gender) const
Returns a gendered variant of this unit_type.
Definition: types.cpp:416
const std::string & image() const
Definition: types.hpp:180
std::vector< std::string > get_ability_id_list() const
Definition: types.cpp:564
config::const_child_itors advancements() const
Definition: types.hpp:243
variations_map variations_
Definition: types.hpp:354
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:146
int level_
Definition: types.hpp:334
const std::string & variation_id() const
The id of this variation; empty if it's a gender variation or a base unit.
Definition: types.hpp:151
const unit_race * race_
Never nullptr, but may point to the null race.
Definition: types.hpp:360
std::string parent_id_
The id of the top ancestor of this unit_type.
Definition: types.hpp:326
ability_vector abilities_
Definition: types.hpp:365
std::string flag_rgb_
Definition: types.hpp:348
const std::string & id() const
The id for this unit_type.
Definition: types.hpp:145
std::string undead_variation_
Definition: types.hpp:342
bool has_random_traits() const
Definition: types.cpp:681
std::string movement_type_id_
Definition: types.hpp:376
const std::vector< ability_metadata > & adv_abilities_metadata() const
Some extra abilities that may be gained through AMLA advancements.
Definition: types.hpp:227
void fill_variations_and_gender()
Definition: types.cpp:1042
const movetype & movement_type() const
Definition: types.hpp:193
std::string halo() const
Definition: types.hpp:184
std::vector< ability_metadata > adv_abilities_infos_
Definition: types.hpp:363
bool show_variations_in_help() const
Whether the unit type has at least one help-visible variation.
Definition: types.cpp:723
const unit_race * race() const
Never returns nullptr, but may point to the null race.
Definition: types.hpp:280
int hitpoints() const
Definition: types.hpp:165
int max_attacks_
Definition: types.hpp:339
std::map< std::string, unit_type > variations_map
Definition: types.hpp:97
std::string debug_id_
A suffix for id_, used when logging messages.
Definition: types.hpp:324
std::array< std::unique_ptr< unit_type >, 2 > gender_types_
Definition: types.hpp:352
double xp_bar_scaling() const
Definition: types.hpp:167
bool has_ability_by_id(const std::string &ability) const
Definition: types.cpp:553
const std::string & default_variation() const
Definition: types.hpp:177
std::string small_profile_
Definition: types.hpp:346
t_string variation_name_
Definition: types.hpp:357
const unit_type & get_variation(const std::string &id) const
Definition: types.cpp:437
const_attack_itors attacks() const
Definition: types.cpp:505
const std::string & usage() const
Definition: types.hpp:179
config::const_child_itors events() const
Definition: types.hpp:246
const std::vector< std::string > & advances_to() const
A vector of unit_type ids that this unit_type can advance to.
Definition: types.hpp:119
unit_type(unit_type &&) noexcept=default
void apply_scenario_fix(const config &cfg)
Definition: types.cpp:1385
int vision_
Definition: types.hpp:337
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 variations_map & variation_types() const
Definition: types.hpp:259
int resistance_against(const std::string &damage_name, bool attacker) const
Gets resistance while considering custom WML abilities.
Definition: types.cpp:734
bool has_variation(const std::string &variation_id) const
Definition: types.cpp:718
bool has_gender_variation(const unit_race::GENDER gender) const
Definition: types.cpp:701
bool hide_help_
Definition: types.hpp:367
bool do_not_list() const
Definition: types.hpp:282
std::string ellipse() const
Definition: types.hpp:185
int movement() const
Definition: types.hpp:170
t_string unit_description() const
Definition: types.cpp:447
config & writable_cfg()
Definition: types.hpp:307
static void check_id(std::string &id)
Validate the id argument.
Definition: types.cpp:1484
BUILD_STATUS
Records the status of the lazy building of unit types.
Definition: types.hpp:77
@ CREATED
Definition: types.hpp:77
@ NOT_BUILT
Definition: types.hpp:77
@ HELP_INDEXED
Definition: types.hpp:77
@ FULL
Definition: types.hpp:77
@ VARIATIONS
Definition: types.hpp:77
std::string id_
Definition: types.hpp:322
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:255
std::string usage_
Definition: types.hpp:341
const std::vector< unit_animation > & animations() const
Definition: types.cpp:496
int max_attacks() const
Definition: types.hpp:175
std::vector< std::string > variations() const
Definition: types.cpp:706
bool hide_help() const
Definition: types.cpp:582
const std::string & flag_rgb() const
Definition: types.cpp:676
std::vector< ability_metadata > abilities_infos_
Definition: types.hpp:362
int vision() const
Definition: types.hpp:171
std::string variation_id_
Definition: types.hpp:356
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:456
attack_list attacks_cache_
Definition: types.hpp:320
config::const_child_itors modification_advancements() const
Returns two iterators pointing to a range of AMLA configs.
Definition: types.hpp:124
int cost() const
Definition: types.hpp:176
double xp_bar_scaling_
Definition: types.hpp:333
std::vector< std::string > advances_to_
Definition: types.hpp:369
const config * cfg_
Definition: types.hpp:317
std::string base_unit_id_
from [base_unit]
Definition: types.hpp:328
double hp_bar_scaling_
Definition: types.hpp:333
config possible_traits_
Definition: types.hpp:379
const std::string log_id() const
A variant on id() that is more descriptive, for use with message logging.
Definition: types.hpp:147
int vision(bool base_value) const
If base_value is set to true, do not fall back to movement().
Definition: types.hpp:173
std::vector< unit_race::GENDER > genders_
Definition: types.hpp:381
bool zoc_
Definition: types.hpp:367
const std::string & icon() const
Definition: types.hpp:181
const t_string & variation_name() const
Definition: types.hpp:178
int experience_needed(bool with_acceleration=true) const
Definition: types.cpp:539
bool generate_name() const
Definition: types.hpp:186
const std::string & big_profile() const
Definition: types.hpp:183
bool musthave_status(const std::string &status) const
Definition: types.cpp:630
const std::string & undead_variation() const
Info on the type of unit that the unit reanimates as.
Definition: types.hpp:137
double hp_bar_scaling() const
Definition: types.hpp:166
unit_type(default_ctor_t, const config &cfg, const std::string &parent_id)
Definition: types.cpp:55
int experience_needed_
Definition: types.hpp:371
movetype movement_type_
Definition: types.hpp:377
std::string icon_
Definition: types.hpp:345
int hitpoints_
Definition: types.hpp:332
const std::string movement_type_id() const
Definition: types.hpp:192
bool do_not_list_
Definition: types.hpp:367
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:381
config abilities_cfg() const
Definition: types.cpp:578
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:766
const t_string & type_name() const
The name of the unit in the current language setting.
Definition: types.hpp:142
void remove_scenario_fixes()
Definition: types.cpp:1454
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:996
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:189
BUILD_STATUS build_status_
Definition: types.hpp:386
config::const_child_itors possible_traits() const
Definition: types.hpp:238
void build_created()
Load the most needed data into an empty unit_type (build to CREATE).
Definition: types.cpp:338
int level() const
Definition: types.hpp:168
std::unique_ptr< config > built_cfg_
Definition: types.hpp:319
bool has_zoc() const
Definition: types.hpp:233
unit_alignments::type alignment() const
Definition: types.hpp:197
const std::string & small_profile() const
Definition: types.hpp:182
t_string type_name_
Definition: types.hpp:329
const std::vector< ability_metadata > & abilities_metadata() const
Definition: types.hpp:224
unit_type(const unit_type &)=delete
const config & get_cfg() const
Definition: types.hpp:284
int movement_
Definition: types.hpp:336
unsigned int num_traits() const
Definition: types.hpp:139
unit_type & operator=(const unit_type &)=delete
unsigned int num_traits_
Definition: types.hpp:350
std::set< std::string > advancement_tree() const
Get the advancement tree.
Definition: types.cpp:603
std::string profile_
Definition: types.hpp:347
int recall_cost() const
Definition: types.hpp:169
int jamming() const
Definition: types.hpp:174
const config * cfg
std::size_t i
Definition: function.cpp:1032
std::vector< std::reference_wrapper< const config > > config_array_view
std::map< std::string, unit_race > race_map
Definition: race.hpp:104
unit_experience_accelerator(int modifier)
Definition: types.cpp:523
static int get_acceleration()
Definition: types.cpp:534
std::string help_topic_id
Definition: types.hpp:207
ability_metadata(const config &cfg)
Definition: types.cpp:127
std::vector< t_string > combine_special_notes(const std::vector< t_string > &direct, const config &abilities, const const_attack_itors &attacks, const movetype &mt)
Common logic for unit_type::special_notes() and unit::special_notes().
Definition: types.cpp:469
unit_type_data unit_types
Definition: types.cpp:1514
std::map< std::string, movetype > movement_type_map
Definition: types.hpp:33
void adjust_profile(std::string &profile)
Definition: types.cpp:1516