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::trait_nonhidden_ids () const |
Gets the ids of the traits corresponding to those returned by trait_names() and trait_descriptions(). More... | |
std::vector< std::string > | unit::get_modifications_list (const std::string &mod_type) const |
Gets a list of the modification this unit currently has. More... | |
std::vector< std::string > | unit::get_traits_list () const |
Gets a list of the traits this unit currently has, including hidden traits. More... | |
std::vector< std::string > | unit::get_objects_list () const |
std::vector< std::string > | unit::get_advancements_list () const |
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... | |
void | unit::set_loyal (bool loyal) |
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 2542 of file unit.cpp.
References t_string::empty(), unit_race::FEMALE, unit::gender_, gender_string(), unit::name(), unit::trait_descriptions_, unit::trait_names_, and unit::trait_nonhidden_ids_.
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 801 of file unit.cpp.
References config::add_child(), c, unit::can_recruit(), config::child_range(), config::erase(), 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().
|
inline |
Definition at line 1145 of file unit.hpp.
References unit::get_modifications_list().
Referenced by wfl::unit_callable::get_value().
std::vector< std::string > unit::get_modifications_list | ( | const std::string & | mod_type | ) | const |
Gets a list of the modification this unit currently has.
mod_type | type of modification. |
Definition at line 934 of file unit.cpp.
References config::child_range(), and unit::modifications_.
Referenced by unit::get_advancements_list(), unit::get_objects_list(), and unit::get_traits_list().
|
inline |
Definition at line 1140 of file unit.hpp.
References unit::get_modifications_list().
Referenced by wfl::unit_callable::get_value().
|
inline |
Gets a list of the traits this unit currently has, including hidden traits.
Definition at line 1135 of file unit.hpp.
References unit::get_modifications_list().
Referenced by gui2::dialogs::add_unit_entry(), unit_filter_impl::unit_filter_compound::fill(), wfl::unit_callable::get_value(), and UNIT_GETTER().
|
inline |
Gets whether this unit is fearless - ie, unaffected by time of day.
Definition at line 1294 of file unit.hpp.
References unit::is_fearless_.
Referenced by attack_info(), battle_context_unit_stats::battle_context_unit_stats(), wfl::unit_callable::get_value(), gui2::dialogs::attack_predictions::set_data(), unit_alignment(), and UNIT_GETTER().
|
inline |
Gets whether this unit is healthy - ie, always rest heals.
Definition at line 1300 of file unit.hpp.
References unit::is_healthy_.
Referenced by wfl::unit_callable::get_value(), and UNIT_GETTER().
bool unit::loyal | ( | ) | const |
Gets whether this unit is loyal - ie, it costs no upkeep.
Definition at line 1700 of file unit.cpp.
References unit::upkeep_.
Referenced by gui2::dialogs::unit_recall::dismiss_unit(), unit::set_loyal(), and editor::map_context::to_config().
void unit::set_loyal | ( | bool | loyal | ) |
Definition at line 1705 of file unit.cpp.
References utils::erase(), unit::loyal(), unit::overlays_, and unit::upkeep_.
|
inline |
Sets the upkeep value to a specific value value.
Does not necessarily need to be numeric
Definition at line 1283 of file unit.hpp.
References unit::upkeep_.
Referenced by UNIT_SETTER().
|
inline |
Gets the descriptions of the currently registered traits.
Definition at line 1108 of file unit.hpp.
References unit::trait_descriptions_.
Referenced by gui2::unit_preview_pane::set_displayed_unit(), and unit_traits().
|
inline |
Gets the names of the currently registered traits.
Definition at line 1098 of file unit.hpp.
References unit::trait_names_.
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().
|
inline |
Gets the ids of the traits corresponding to those returned by trait_names() and trait_descriptions().
Omits hidden traits, which are those with an empty name.
Definition at line 1119 of file unit.hpp.
References unit::trait_nonhidden_ids_.
Referenced by 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 1690 of file unit.cpp.
References unit::can_recruit(), and unit::upkeep_.
Referenced by unit_filter_impl::unit_filter_compound::fill(), wfl::unit_callable::get_value(), unit::parse_upkeep(), display_context::side_upkeep(), and unit::write_upkeep().
|
inline |
Gets the raw variant controlling the upkeep value.
This should not usually be called directly. To get an actual numeric value of upkeep use upkeep.
Definition at line 1277 of file unit.hpp.
References unit::upkeep_.
Referenced by UNIT_GETTER().