The Battle for Wesnoth  1.15.2+dev
Typedefs | Functions
Advancement functions

Typedefs

using unit::advances_to_t = std::vector< std::string >
 
using unit::advancements_list = boost::ptr_vector< config >
 

Functions

void unit::advance_to (const unit_type &t, bool use_traits=false)
 Advances this unit to another type. More...
 
const advances_to_tunit::advances_to () const
 Gets the possible types this unit can advance to on level-up. More...
 
const std::vector< std::string > unit::advances_to_translated () const
 Gets the names of the possible types this unit can advance to on level-up. More...
 
void unit::set_advances_to (const std::vector< std::string > &advances_to)
 Sets this unit's advancement options. More...
 
bool unit::can_advance () const
 Checks whether this unit has any options to advance to. More...
 
bool unit::advances () const
 Checks whether this unit is eligible for level-up. More...
 
std::map< std::string, std::string > unit::advancement_icons () const
 Gets and image path and and associated description for each advancement option. More...
 
std::vector< configunit::get_modification_advances () const
 Gets any non-typed advanced options set by modifications. More...
 
std::vector< std::pair< std::string, std::string > > unit::amla_icons () const
 Gets the image and description data for modification advancements. More...
 
const advancements_listunit::modification_advancements () const
 The raw, unparsed data for modification advancements. More...
 
void unit::set_advancements (std::vector< config > advancements)
 Sets the raw modification advancement option data. More...
 

Detailed Description

Typedef Documentation

◆ advancements_list

using unit::advancements_list = boost::ptr_vector<config>

Definition at line 282 of file unit.hpp.

◆ advances_to_t

using unit::advances_to_t = std::vector<std::string>

Definition at line 198 of file unit.hpp.

Function Documentation

◆ advance_to()

void unit::advance_to ( const unit_type u_type,
bool  use_traits = false 
)

Advances this unit to another type.

Advances this unit to the specified type.

Experience is left unchanged. Current hit point total is left unchanged unless it would violate max HP. Assumes gender_ and variation_ are set to their correct values.

Definition at line 922 of file unit.cpp.

References unit::abilities_, unit_type::abilities_cfg(), game_events::manager::add_events(), unit_type::advancements(), unit::advancements_, unit_type::advances_to(), unit::advances_to_, unit::alignment_, unit::anim_comp_, unit::appearance_changed_, unit::apply_modifications(), unit_type::attacks(), unit::attacks_, unit_type::big_profile(), unit::clear_changed_attributes(), unit_type::cost(), unit::description_, unit_type::ellipse(), unit::ellipse_, unit::emit_zoc_, unit_type::events(), unit_type::experience_needed(), unit_type::flag_rgb(), unit::flag_rgb_, resources::game_events, unit::gender_, unit_type::generate_name(), unit::generate_name_, unit::generate_traits(), unit::get_attr_changed(), unit_type::get_cfg(), unit_type::get_cfg_for_units(), unit_type::get_gender_unit_type(), unit::get_state(), unit_type::get_variation(), unit_type::halo(), unit_type::has_zoc(), unit::hit_points_, unit_type::hitpoints(), unit_type::hp_bar_scaling(), unit::hp_bar_scaling_, unit_type::id(), unit::image_mods_, unit::is_fearless_, unit::is_healthy_, unit_type::jamming(), unit::jamming_, unit_type::level(), unit::level_, unit_type::max_attacks(), unit::max_attacks_, unit::max_experience_, unit::max_hit_points_, unit::max_movement_, unit::modification_descriptions_, unit_type::movement(), unit_type::movement_type(), unit::movement_type_, unit::overlays_, unit::parse_upkeep(), unit::profile_, unit_type::race(), unit::race_, unit::random_traits_, unit_type::recall_cost(), unit::recall_cost_, unit::set_attr_changed(), unit::set_image_ellipse(), unit::set_image_halo(), unit::set_state(), unit::set_usage(), unit_type::small_profile(), unit::small_profile_, unit_type::special_notes(), unit::special_notes_, unit::STATE_POISONED, unit::trait_descriptions_, unit::trait_names_, unit::type(), unit::type_, unit_type::type_name(), unit::type_name_, unit::UA_PROFILE, unit::UA_SMALL_PROFILE, unit_type::undead_variation(), unit::undead_variation_, unit_type::unit_description(), unit::unit_value_, unit::upkeep_, unit_type::usage(), unit::variation_, unit_type::variation_id(), unit_type::vision(), unit::vision_, unit_type::xp_bar_scaling(), and unit::xp_bar_scaling_.

Referenced by unit::apply_builtin_effect(), unit::expire_modifications(), unit::init(), and intf_transform_unit().

◆ advancement_icons()

std::map< std::string, std::string > unit::advancement_icons ( ) const

Gets and image path and and associated description for each advancement option.

Covers both type and modification-based advancements.

Returns
A data map, in image/description format. If the option is a unit type, advancement, the key is the type's image and the value the type ID.

If the option is a modification, the key and value are set from config data (see get_modification_advances).

Definition at line 1705 of file unit.cpp.

References unit::advances_to(), unit::advances_to_, unit::can_advance(), unit::get_modification_advances(), game_config::images::level, and s.

Referenced by unit_advancement_options().

◆ advances()

bool unit::advances ( ) const
inline

Checks whether this unit is eligible for level-up.

Return values
trueThis unit has sufficient experience to level up and has advancement options available.

Definition at line 243 of file unit.hpp.

◆ advances_to()

const advances_to_t& unit::advances_to ( ) const
inline

Gets the possible types this unit can advance to on level-up.

Returns
A list of type IDs this unit may advance to.

Definition at line 204 of file unit.hpp.

Referenced by unit::advancement_icons(), wfl::unit_callable::get_value(), unit_helper::number_of_possible_advances(), unit::set_advances_to(), and unit::xp_color().

◆ advances_to_translated()

const std::vector< std::string > unit::advances_to_translated ( ) const

Gets the names of the possible types this unit can advance to on level-up.

Returns
A list of the names of the types this unit may advance to.

Definition at line 1186 of file unit.cpp.

References unit::advances_to_, unit_type_data::find(), unit_type::log_id(), unit::type(), unit_types, and WRN_UT.

Referenced by unit_level().

◆ amla_icons()

std::vector< std::pair< std::string, std::string > > unit::amla_icons ( ) const

Gets the image and description data for modification advancements.

Returns
A list of pairs of the image paths(first) and descriptions (second) for each advancement option.

Definition at line 1745 of file unit.cpp.

References unit::get_modification_advances(), and unit::modification_count().

Referenced by REPORT_GENERATOR().

◆ can_advance()

bool unit::can_advance ( ) const
inline

Checks whether this unit has any options to advance to.

This considers both whether it has types to advance to OR whether any modifications specify non-type advancement options.

Note this does not consider unit experience at all, it only checks option availability. See advances if an experience check is necessary.

Definition at line 232 of file unit.hpp.

Referenced by unit::advancement_icons(), gui2::dialogs::unit_list::pre_show(), gui2::dialogs::unit_recall::pre_show(), unit_drawer::redraw_unit(), gui2::unit_preview_pane::set_displayed_unit(), and unit_xp().

◆ get_modification_advances()

std::vector< config > unit::get_modification_advances ( ) const

Gets any non-typed advanced options set by modifications.

These are usually used to give a unit special advancement options that don't invole transforming to a new type.

Note this is not the raw option data. Parsing is performed to ensure each option appears only once. Use modification_advancements is the raw data is needed.

Returns
A config list of options data. Each option is unique.

Definition at line 1762 of file unit.cpp.

References unit::advances_to_, unit::modification_advancements(), unit::modification_count(), s, sort(), and utils::split().

Referenced by unit::advancement_icons(), unit::amla_icons(), unit_helper::number_of_possible_advances(), unit_level(), and unit::xp_color().

◆ modification_advancements()

const advancements_list& unit::modification_advancements ( ) const
inline

The raw, unparsed data for modification advancements.

Definition at line 284 of file unit.hpp.

Referenced by unit::get_modification_advances().

◆ set_advancements()

void unit::set_advancements ( std::vector< config advancements)

Sets the raw modification advancement option data.

Definition at line 1822 of file unit.cpp.

References unit::advancements_, unit::set_attr_changed(), and unit::UA_ADVANCEMENTS.

◆ set_advances_to()

void unit::set_advances_to ( const std::vector< std::string > &  advances_to)

Sets this unit's advancement options.

Parameters
advances_toA list of new type IDs this unit may advance to.

Definition at line 1201 of file unit.cpp.

References unit::advances_to(), unit::advances_to_, unit_type_data::check_types(), unit::set_attr_changed(), unit::UA_ADVANCE_TO, and unit_types.

Referenced by unit::init().