Classes | |
struct | unit::upkeep_full |
struct | unit::upkeep_loyal |
class | unit::upkeep_value_visitor |
Visitor helper class to fetch the appropriate upkeep value. More... | |
struct | unit::upkeep_type_visitor |
Visitor helper struct to fetch the upkeep type flag if applicable, or the the value otherwise. More... | |
class | unit::upkeep_parser_visitor |
Visitor helper class to parse the upkeep value from a config. More... | |
Typedefs | |
using | unit::upkeep_t = utils::variant< upkeep_full, upkeep_loyal, int > |
Functions | |
void | unit::generate_traits (bool must_have_only=false) |
Applies mandatory traits (e.g. More... | |
const std::vector< t_string > & | unit::trait_names () const |
Gets the names of the currently registered traits. More... | |
const std::vector< t_string > & | unit::trait_descriptions () const |
Gets the descriptions of the currently registered traits. More... | |
std::vector< std::string > | unit::get_traits_list () const |
Gets a list of the traits this unit currently has. More... | |
void | unit::add_trait_description (const config &trait, const t_string &description) |
Register a trait's name and its description for the UI's use. More... | |
int | unit::upkeep () const |
Gets the amount of gold this unit costs a side per turn. More... | |
upkeep_t | unit::upkeep_raw () const |
Gets the raw variant controlling the upkeep value. More... | |
void | unit::set_upkeep (upkeep_t v) |
Sets the upkeep value to a specific value value. More... | |
bool | unit::loyal () const |
Gets whether this unit is loyal - ie, it costs no upkeep. More... | |
bool | unit::is_fearless () const |
Gets whether this unit is fearless - ie, unaffected by time of day. More... | |
bool | unit::is_healthy () const |
Gets whether this unit is healthy - ie, always rest heals. More... | |
using unit::upkeep_t = utils::variant<upkeep_full, upkeep_loyal, int> |
Register a trait's name and its description for the UI's use.
The resulting data can be fetched with trait_names and trait_descriptions.
trait | A config containing the trait's attributes. |
description | The translatable description of the trait. |
Definition at line 2478 of file unit.cpp.
References t_string::empty(), unit_race::FEMALE, unit::gender_, gender_string(), unit::name(), unit::trait_descriptions_, and unit::trait_names_.
Referenced by unit::add_modification().
void unit::generate_traits | ( | bool | must_have_only = false | ) |
Applies mandatory traits (e.g.
undead, mechanical) to a unit and then fills in the remaining traits traits until no more are available (leaders have a restricted set of available traits) or the unit has its maximum number of traits.
This routine does not apply the effects of added traits to a unit; that must be done by the caller.
Note that random numbers used in config files don't work in multiplayer, so leaders should be barred from all random traits until that is fixed. Later the restrictions will be based on play balance.
must_have_only | Whether random or optional traits should be included or not. If false only mandatory traits will be used. |
Definition at line 804 of file unit.cpp.
References config::add_child(), c, unit::can_recruit(), config::child_range(), randomness::generator, randomness::rng::get_random_int(), unit_type::log_id(), LOG_UT, unit::modifications_, unit_type::num_traits(), unit_type::possible_traits(), unit::random_traits_, s, utils::split(), t, and unit::type().
Referenced by unit::advance_to().
std::vector< std::string > unit::get_traits_list | ( | ) | const |
Gets a list of the traits this unit currently has.
Definition at line 937 of file unit.cpp.
References config::child_range(), and unit::modifications_.
Referenced by gui2::dialogs::add_unit_entry(), wfl::unit_callable::get_value(), and unit_traits().
|
inline |
Gets whether this unit is fearless - ie, unaffected by time of day.
Definition at line 1250 of file unit.hpp.
Referenced by attack_info(), battle_context_unit_stats::battle_context_unit_stats(), gui2::dialogs::attack_predictions::set_data(), and unit_alignment().
|
inline |
bool unit::loyal | ( | ) | const |
Gets whether this unit is loyal - ie, it costs no upkeep.
Definition at line 1682 of file unit.cpp.
References unit::upkeep_.
Referenced by gui2::dialogs::unit_recall::dismiss_unit().
|
inline |
|
inline |
Gets the descriptions of the currently registered traits.
Definition at line 1096 of file unit.hpp.
Referenced by gui2::unit_preview_pane::set_displayed_unit(), and unit_traits().
|
inline |
Gets the names of the currently registered traits.
Definition at line 1086 of file unit.hpp.
Referenced by gui2::dialogs::unit_list::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::unit_recall::rename_unit(), gui2::unit_preview_pane::set_displayed_unit(), and unit_traits().
int unit::upkeep | ( | ) | const |
Gets the amount of gold this unit costs a side per turn.
This fetches an actual numeric gold value:
Definition at line 1672 of file unit.cpp.
References unit::can_recruit(), and unit::upkeep_.
Referenced by wfl::unit_callable::get_value().