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

Typedefs

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

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 std::vector< config > & unit::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

◆ advances_to_t

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

Definition at line 238 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 hitpoints/movement/attacks_left is left unchanged unless it would violate their maximum. Assumes gender_ and variation_ are set to their correct values.

Definition at line 970 of file unit.cpp.

References unit::abilities(), unit::abilities_, unit_type::abilities_cfg(), game_events::manager::add_events(), unit_type::advancements(), unit::advancements_, unit_type::advances_to(), unit::advances_to_, unit_type::alignment(), unit::alignment_, config::all_children_view(), unit::anim_comp_, unit::appearance_changed_, unit::apply_modifications(), unit_type::attacks(), unit::attacks_, unit_type::big_profile(), config::child_range(), unit::clear_changed_attributes(), unit_type::cost(), unit::description_, unit_type::direct_special_notes(), unit_type::ellipse(), unit::ellipse_, unit::emit_zoc_, 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_gender_unit_type(), unit::get_state(), unit_type::get_variation(), unit_type::halo(), unit_type::has_zoc(), 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_, resources::lua_kernel, 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::special_notes_, unit::STATE_PETRIFIED, unit::trait_descriptions_, unit::trait_names_, unit::trait_nonhidden_ids_, 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 1805 of file unit.cpp.

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

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 283 of file unit.hpp.

References unit::can_advance(), unit::experience_, and unit::max_experience().

◆ 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 244 of file unit.hpp.

References unit::advances_to_.

Referenced by unit::advancement_icons(), wfl::unit_callable::get_value(), unit_helper::number_of_possible_advances(), unit::set_advances_to(), UNIT_GETTER(), 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 1234 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_helper::unit_level_tooltip().

◆ 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 1845 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 272 of file unit.hpp.

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

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

◆ 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 1862 of file unit.cpp.

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

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

◆ modification_advancements()

const std::vector<config>& unit::modification_advancements ( ) const
inline

The raw, unparsed data for modification advancements.

Definition at line 323 of file unit.hpp.

References unit::advancements_.

Referenced by unit::get_modification_advances(), and UNIT_GETTER().

◆ set_advancements()

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

Sets the raw modification advancement option data.

Definition at line 1927 of file unit.cpp.

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

Referenced by UNIT_SETTER().

◆ 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 1249 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(), and UNIT_SETTER().