82 static void check_id(std::string&
id);
105 {
const_cast<unit_type *
>(
this)->
build(status, movement_types, races, traits); }
141 const std::string&
id()
const {
return id_; }
183 const std::vector<unit_animation>&
animations()
const;
185 const std::string&
flag_rgb()
const;
413 bool hide_help(
const std::string &type_id,
const std::string &race_id)
const;
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.
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.
child_itors child_range(config_key_type key)
boost::iterator_range< const_child_iterator > const_child_itors
A class grating read only view to a vector of config objects, viewed as one config with all children ...
config_array_view child_range(config_key_type key) const
The basic "size" of the unit - flying, small land, large land, etc.
const movement_type_map & movement_types() const
void set_config(const game_config_view &cfg)
Resets all data based on the provided config.
unit_type::BUILD_STATUS build_status_
std::map< std::string, unit_type > unit_type_map
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.
bool hide_help(const std::string &type_id, const std::string &race_id) const
Checks if the [hide_help] tag contains these IDs.
void remove_scenario_fixes()
const race_map & races() const
bool hide_help_all_
True if [hide_help] contains a 'all=yes' at its root.
void build_all(unit_type::BUILD_STATUS status)
Makes sure the all unit_types are built to the specified level.
void apply_base_unit(unit_type &type, std::vector< std::string > &base_tree)
Modifies the provided config by merging all base units into it.
const unit_race * find_race(const std::string &) const
void check_types(const std::vector< std::string > &types) const
movement_type_map movement_types_
game_config_view units_cfg_
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.
std::vector< std::set< std::string > > hide_help_type_
const game_config_view & units_cfg() const
const unit_type_map & types() const
void read_hide_help(const config &cfg)
Parses the [hide_help] tag.
unit_type_data & operator=(const unit_type_data &)=delete
void apply_scenario_fix(const config &cfg)
unit_type_data(const unit_type_data &)=delete
config_array_view traits() const
std::vector< std::set< std::string > > hide_help_race_
A single unit type that the player may recruit.
std::string default_variation_
std::vector< unit_animation > animations_
const std::vector< std::string > advances_from() const
A vector of unit_type ids that can advance to this unit_type.
unit_alignments::type alignment_
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...
std::string race_id() const
Returns the ID of this type's race without the need to build the type.
const std::string & parent_id() const
The id of the original type from which this (variation) descended.
config::const_child_itors advancements_
void fill_variations()
Processes [variation] tags of ut_cfg, handling inheritance and child clearing.
static std::string alignment_description(unit_alignments::type align, unit_race::GENDER gender=unit_race::MALE)
Implementation detail of unit_type::alignment_description.
std::vector< t_string > special_notes_
const std::string & image() const
config::const_child_itors advancements() const
variations_map variations_
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).
const std::string & variation_id() const
The id of this variation; empty if it's a gender variation or a base unit.
const unit_race * race_
Never nullptr, but may point to the null race.
std::map< std::string, unit_type > variations_map
std::string parent_id_
The id of the top ancestor of this unit_type.
const std::string & id() const
The id for this unit_type.
std::string undead_variation_
unit_type & operator=(const unit_type &o)=delete
bool has_random_traits() const
std::string movement_type_id_
const std::vector< ability_metadata > & adv_abilities_metadata() const
Some extra abilities that may be gained through AMLA advancements.
std::vector< ability_metadata > abilities_
void fill_variations_and_gender()
const movetype & movement_type() const
bool show_variations_in_help() const
Whether the unit type has at least one help-visible variation.
const unit_race * race() const
Never returns nullptr, but may point to the null race.
std::string debug_id_
A suffix for id_, used when logging messages.
std::array< std::unique_ptr< unit_type >, 2 > gender_types_
double xp_bar_scaling() const
bool has_ability_by_id(const std::string &ability) const
unit_type(unit_type &&o)=default
const std::string & default_variation() const
std::string small_profile_
const unit_type & get_variation(const std::string &id) const
const_attack_itors attacks() const
const std::string & usage() const
config::const_child_itors events() const
const std::vector< std::string > & advances_to() const
A vector of unit_type ids that this unit_type can advance to.
void apply_scenario_fix(const config &cfg)
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.
const variations_map & variation_types() const
int resistance_against(const std::string &damage_name, bool attacker) const
Gets resistance while considering custom WML abilities.
bool has_variation(const std::string &variation_id) const
bool has_gender_variation(const unit_race::GENDER gender) const
std::string ellipse() const
t_string unit_description() const
static void check_id(std::string &id)
Validate the id argument.
BUILD_STATUS
Records the status of the lazy building of unit types.
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.
const std::vector< unit_animation > & animations() const
std::vector< std::string > variations() const
const std::string & flag_rgb() const
const config & abilities_cfg() const
std::string variation_id_
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...
attack_list attacks_cache_
config::const_child_itors modification_advancements() const
Returns two iterators pointing to a range of AMLA configs.
std::vector< std::string > advances_to_
std::string base_unit_id_
from [base_unit]
const std::string log_id() const
A variant on id() that is more descriptive, for use with message logging.
int vision(bool base_value) const
If base_value is set to true, do not fall back to movement().
const unit_type & get_gender_unit_type(std::string gender) const
Returns a gendered variant of this unit_type.
std::vector< unit_race::GENDER > genders_
const std::string & icon() const
const t_string & variation_name() const
int experience_needed(bool with_acceleration=true) const
bool generate_name() const
const std::string & big_profile() const
bool musthave_status(const std::string &status) const
const std::string & undead_variation() const
Info on the type of unit that the unit reanimates as.
double hp_bar_scaling() const
const std::string movement_type_id() const
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.
std::vector< std::string > get_ability_list() const
bool resistance_filter_matches(const config &cfg, bool attacker, const std::string &damage_name, int res) const
Identical to unit::resistance_filter_matches.
const t_string & type_name() const
The name of the unit in the current language setting.
void remove_scenario_fixes()
std::unique_ptr< unit_type > create_sub_type(const config &var_cfg, bool default_inherit)
Handles inheritance for configs of [male], [female], and [variation].
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).
BUILD_STATUS build_status_
config::const_child_itors possible_traits() const
void build_created()
Load the most needed data into an empty unit_type (build to CREATE).
std::unique_ptr< config > built_cfg_
std::vector< ability_metadata > adv_abilities_
unit_alignments::type alignment() const
const std::string & small_profile() const
const std::vector< ability_metadata > & abilities_metadata() const
const config & get_cfg() const
unsigned int num_traits() const
std::set< std::string > advancement_tree() const
Get the advancement tree.
std::vector< std::reference_wrapper< const config > > config_array_view
std::map< std::string, unit_race > race_map
~unit_experience_accelerator()
unit_experience_accelerator(int modifier)
static int get_acceleration()
unit_type_data unit_types
std::map< std::string, movetype > movement_type_map
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().
void adjust_profile(std::string &profile)