The Battle for Wesnoth  1.19.0-dev
Functions
unit_helper Namespace Reference

Functions

int number_of_possible_advances (const unit &unit)
 Determines the total number of available advancements (of any kind) for a given unit. More...
 
bool will_certainly_advance (const unit_map::iterator &u)
 Encapsulates the logic for deciding whether an iterator u points to a unit that can advance. More...
 
std::string resistance_color (const int resistance)
 Maps resistance <= -60 (resistance value <= -60%) to intense red. More...
 
static std::string unit_level_tooltip (const int level, const std::vector< std::string > &adv_to_types, const std::vector< config > &adv_to_mods)
 
std::string unit_level_tooltip (const unit &u)
 
std::string unit_level_tooltip (const unit_type &type)
 

Function Documentation

◆ number_of_possible_advances()

int unit_helper::number_of_possible_advances ( const unit unit)

Determines the total number of available advancements (of any kind) for a given unit.

This includes normal advances and modifiers.

Returns
the total number of possible advancements.

Definition at line 28 of file helper.cpp.

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

Referenced by ai::helper_advance_unit(), and will_certainly_advance().

◆ resistance_color()

std::string unit_helper::resistance_color ( const int  resistance)

Maps resistance <= -60 (resistance value <= -60%) to intense red.

Maps resistance >= 60 (resistance value >= 60%) to intense green. Intermediate values are affinely mapped to the red-to-green scale, with 0 (0%) being mapped to yellow. Compare attack_info_percent_color() in reports.cpp.

Returns
the name of the color encoding the weight of the unit's resistance value for presenting it to the player.

Definition at line 48 of file helper.cpp.

References game_config::red_to_green(), and color_t::to_hex_string().

Referenced by gui2::get_hp_tooltip(), help::unit_topic_generator::operator()(), and unit_hp().

◆ unit_level_tooltip() [1/3]

static std::string unit_helper::unit_level_tooltip ( const int  level,
const std::vector< std::string > &  adv_to_types,
const std::vector< config > &  adv_to_mods 
)
static

◆ unit_level_tooltip() [2/3]

std::string unit_helper::unit_level_tooltip ( const unit u)
Returns
the tooltip text showing a unit's level and what it can advance to.

Definition at line 78 of file helper.cpp.

References unit::advances_to_translated(), unit::get_modification_advances(), unit::level(), and unit_level_tooltip().

◆ unit_level_tooltip() [3/3]

std::string unit_helper::unit_level_tooltip ( const unit_type u)
Returns
the tooltip text showing a unit type's level and what it can advance to.

Definition at line 83 of file helper.cpp.

References unit_level_tooltip().

◆ will_certainly_advance()

bool unit_helper::will_certainly_advance ( const unit_map::iterator u)

Encapsulates the logic for deciding whether an iterator u points to a unit that can advance.

Returns
true if the unit exists, has available advances, and can_advance().

Definition at line 33 of file helper.cpp.

References number_of_possible_advances(), and unit_map::iterator_base< iter_types >::valid().

Referenced by ai::helper_advance_unit().