71 std::pair<int, map_location>
highest(
const std::string& key,
int def=0)
const
75 std::pair<int, map_location>
lowest(
const std::string& key,
int def=0)
const
80 template<
typename TComp>
81 std::pair<int, map_location>
get_extremum(
const std::string& key,
int def,
const TComp& comp)
const;
103 template<
typename... T>
111 std::copy(other.
begin(), other.
end(), std::back_inserter(
cfgs_ ));
120 template<
typename Predicate>
123 std::copy_if(other.
begin(), other.
end(), std::back_inserter(
cfgs_ ), predicate);
135 class unit :
public std::enable_shared_from_this<unit>
207 res->init(
cfg, use_traits, vcfg);
226 return std::shared_ptr<unit>(
new unit(*
this));
323 std::vector<std::pair<std::string, std::string>>
amla_icons()
const;
369 const std::string&
type_id()
const;
383 const std::string&
id()
const
707 return usage_.value_or(
"");
838 void heal(
int amount);
852 const std::set<std::string>
get_states()
const;
859 bool get_state(
const std::string& state)
const;
866 void set_state(
const std::string& state,
bool value);
961 template<
typename... Args>
1192 static std::string
type() {
static std::string v =
"full";
return v; }
1197 static std::string
type() {
static std::string v =
"loyal";
return v; }
1200 using upkeep_t = utils::variant<upkeep_full, upkeep_loyal, int>;
1204 #ifdef USING_BOOST_VARIANT
1205 :
public boost::static_visitor<int>
1234 #ifdef USING_BOOST_VARIANT
1235 :
public boost::static_visitor<std::string>
1238 template<
typename T>
1239 std::enable_if_t<!std::is_same_v<int, T>, std::string>
1248 return std::to_string(v);
1254 #ifdef USING_BOOST_VARIANT
1255 :
public boost::static_visitor<upkeep_t>
1259 template<
typename N>
1260 std::enable_if_t<std::is_arithmetic_v<N>,
upkeep_t>
1264 if(
n < 0)
throw std::invalid_argument(std::to_string(
n));
1265 return static_cast<int>(
n);
1268 template<
typename B>
1269 std::enable_if_t<std::is_convertible_v<B, bool> && !std::is_arithmetic_v<B>,
upkeep_t>
1272 throw std::invalid_argument(
b.str());
1282 if(
s ==
"loyal" ||
s ==
"free")
1286 throw std::invalid_argument(
s);
1405 void set_movement(
int moves,
bool unit_action =
false);
1677 return halo_.value_or(
"");
1707 const std::string&
flag_rgb()
const;
1876 std::vector<std::tuple<std::string, t_string, t_string, t_string>>
1890 std::vector<std::tuple<std::string, t_string, t_string, t_string>>
1957 operator bool()
const;
boost::iterator_range< boost::indirect_iterator< attack_list::iterator > > attack_itors
std::vector< ability_ptr > ability_vector
std::vector< attack_ptr > attack_list
boost::iterator_range< boost::indirect_iterator< attack_list::const_iterator > > const_attack_itors
attack_itors make_attack_itors(attack_list &atks)
std::vector< active_ability >::iterator iterator
void append_if(const active_ability_list &other, const Predicate &predicate)
Appends any abilities from other for which the given condition returns true to this,...
iterator erase(const iterator &first, const iterator &last)
std::vector< active_ability >::const_iterator const_iterator
std::pair< int, map_location > highest(const std::string &key, int def=0) const
std::vector< active_ability > cfgs_
iterator erase(const iterator &erase_it)
const map_location & loc() const
const_iterator begin() const
std::pair< int, map_location > get_extremum(const std::string &key, int def, const TComp &comp) const
void emplace_back(T &&... args)
const active_ability & front() const
active_ability_list(const map_location &loc=map_location())
void append(const active_ability_list &other)
Appends the abilities from other to this, ignores other.loc()
const_iterator end() const
std::pair< int, map_location > lowest(const std::string &key, int def=0) const
const active_ability & back() const
const std::string & type() const
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
The basic "size" of the unit - flying, small land, large land, etc.
int jamming_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to "jam" through the indicated terrain.
int vision_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to see through the indicated terrain.
int movement_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to move through the indicated terrain.
utils::string_map_res damage_table() const
Returns a map from damage types to resistances.
bool is_flying() const
Returns whether or not *this is flagged as a flying movement type.
This class stores all the data for a single 'side' (in game nomenclature).
Helper similar to std::unique_lock for detecting when calculations such as abilities have entered inf...
Visitor helper class to parse the upkeep value from a config.
Visitor helper class to fetch the appropriate upkeep value.
static config vector_to_cfg(const ability_vector &abilities)
static ability_vector filter_tag(const ability_vector &vec, const std::string &tag)
A single unit type that the player may recruit.
This class represents a single unit of a specific type.
unit & operator=(const unit &)=delete
static void clear_status_caches()
Clear this unit status cache for all units.
void set_attr_changed(UNIT_ATTRIBUTE attr)
bool get_attr_changed(UNIT_ATTRIBUTE attr) const
void clear_changed_attributes()
void init(const config &cfg, bool use_traits=false, const vconfig *vcfg=nullptr)
static unit_ptr create(const config &cfg, bool use_traits=false, const vconfig *vcfg=nullptr)
Initializes a unit from a config.
static const std::string & leader_crown()
The path to the leader crown overlay.
bool get_attacks_changed() const
static unit_ptr create(const unit_type &t, int side, bool real_unit, unit_race::GENDER gender=unit_race::NUM_GENDERS, const std::string &variation="")
Initializes a unit from a unit type.
A variable-expanding proxy for the config class.
const ability_vector & abilities() const
void generate_name()
Generates a random race-appropriate name if one has not already been provided.
std::vector< t_string > trait_names_
bool get_self_ability_bool_weapon(const unit_ability_t &ab, const map_location &loc, const const_attack_ptr &weapon=nullptr, const const_attack_ptr &opp_weapon=nullptr) const
Checks whether this unit currently possesses a given ability of leadership type.
bool get_adj_ability_bool_weapon(const unit_ability_t &ab, std::size_t dist, int dir, const map_location &loc, const unit &from, const map_location &from_loc, const const_attack_ptr &weapon, const const_attack_ptr &opp_weapon) const
Checks whether this unit is affected by a given ability of leadership type.
void clear_visibility_cache() const
Clears the cache.
bool ability_active_impl(const unit_ability_t &ab, const map_location &loc) const
Check if an ability is active.
bool ability_affects_self(const unit_ability_t &ab, const map_location &loc) const
Check if an ability affects the owning unit.
bool ability_active(const unit_ability_t &ab, const map_location &loc) const
Check if an ability is active.
ability_vector abilities(const std::string &tag) const
active_ability_list get_abilities(const std::string &tag_name, const map_location &loc) const
Gets the unit's active abilities of a particular type if it were on a specified location.
void remove_ability_by_attribute(const config &filter)
Removes a unit's abilities with a specific ID or other attribute.
std::string undead_variation_
t_string type_name_
The displayed name of this unit type.
map_location interrupted_move_
ability_vector abilities_
unit_movement_resetter(const unit_movement_resetter &)=delete
void write(config &cfg, bool write_all=true) const
Serializes the current unit metadata values.
std::bitset< UA_COUNT > changed_attributes_
std::vector< const config * > open_queries_
While processing a recursive match, all the filters that are currently being checked,...
bool ability_matches_filter(const unit_ability_t &ab, const config &filter) const
Verify what abilities attributes match with filter.
std::string small_profile_
void write_upkeep(config::attribute_value &upkeep) const
bool get_ability_bool(const std::string &tag_name, const map_location &loc) const
Checks whether this unit currently possesses or is affected by a given ability.
bool ability_affects_adjacent(const unit_ability_t &ab, std::size_t dist, int dir, const map_location &loc, const unit &from) const
Check if an ability affects distant units.
void set_favorite(bool favorite)
std::vector< t_string > special_notes_
void set_has_ability_distant()
std::map< std::string, std::size_t > max_ability_radius_type_
Used for easing checking if unit own a ability of specified type with [affect_adjacent] sub tag.
static std::map< std::string, state_t > known_boolean_state_names_
void set_appearance_changed(bool value)
std::vector< std::tuple< std::string, t_string, t_string, t_string > > ability_tooltips() const
Gets the names and descriptions of this unit's abilities.
active_ability_list get_abilities_weapons(const std::string &tag_name, const map_location &loc, const_attack_ptr weapon=nullptr, const_attack_ptr opp_weapon=nullptr) const
utils::optional< std::string > ellipse_
const unit_type * type_
Never nullptr.
std::bitset< num_bool_states > known_boolean_states_
utils::optional< std::string > halo_
map_location::direction facing_
std::shared_ptr< const unit > parent
const unit_race * race_
Never nullptr, but may point to the null race.
int operator()(const upkeep_loyal &) const
Loyal units cost no upkeep.
bool appearance_changed() const
unit_alignments::type alignment_
bool get_ability_bool(const std::string &tag_name) const
Checks whether this unit currently possesses or is affected by a given ability.
bool invisible(const map_location &loc, bool see_all=true) const
bool is_visible_to_team(const team &team, bool const see_all=true) const
active_ability_list get_abilities(const std::string &tag_name) const
Gets the unit's active abilities of a particular type.
std::enable_if_t<!std::is_same_v< int, T >, std::string > operator()(T &) const
n_unit::unit_id underlying_id_
unit & mark_clone(bool is_temporary)
Mark this unit as clone so it can be inserted to unit_map.
bool has_ability_type(const std::string &ability) const
Check if the unit has an ability of a specific type.
std::enable_if_t< std::is_convertible_v< B, bool > &&!std::is_arithmetic_v< B >, upkeep_t > operator()(B b) const
static const std::size_t num_bool_states
unit_race::GENDER gender_
int operator()(int v) const
std::set< std::string > recruit_list_
std::map< map_location, bool > invisibility_cache_
Hold the visibility status cache for a unit, when not uncovered.
recursion_guard()
Construct an empty instance, only useful for extending the lifetime of a recursion_guard returned fro...
upkeep_t operator()(const std::string &s) const
std::vector< std::string > advances_to_
std::unique_ptr< unit_animation_component > anim_comp_
std::enable_if_t< std::is_arithmetic_v< N >, upkeep_t > operator()(N n) const
recursion_guard & operator=(recursion_guard &&) noexcept
static std::string type()
std::vector< std::string > get_ability_list() const
Get a list of all abilities by ID.
void remove_ability_by_id(const std::string &ability)
Removes a unit's abilities with a specific ID.
bool ability_affects_weapon(const unit_ability_t &ab, const const_attack_ptr &weapon, bool is_opp) const
filters the weapons that condition the use of abilities for combat ([resistance],[leadership] or abil...
utils::optional< std::string > usage_
static std::string type()
std::vector< std::string > overlays_
recursion_guard update_variables_recursion(const config &ability) const
bool has_ability_by_id(const std::string &ability) const
Check if the unit has an ability of a specific ID.
config abilities_cfg() const
upkeep_value_visitor(const unit &unit)
std::string operator()(int v) const
bool get_self_ability_bool(const unit_ability_t &ab, const map_location &loc) const
Checks whether this unit currently possesses a given ability, and that that ability is active.
void parse_upkeep(const config::attribute_value &upkeep)
recursion_guard(const recursion_guard &other)=delete
std::vector< config > advancements_
bool get_adj_ability_bool(const unit_ability_t &ab, std::size_t dist, int dir, const map_location &loc, const unit &from, const map_location &from_loc) const
Checks whether this unit is affected by a given ability, and that that ability is active.
utils::string_map modification_descriptions_
upkeep_t operator()(utils::monostate) const
unit_checksum_version
Optional parameter for get_checksum to use the algorithm of an older version of Wesnoth,...
std::vector< std::string > trait_nonhidden_ids_
int operator()(const upkeep_full &) const
Full upkeep equals the unit's level.
std::set< std::string > states_
std::size_t max_ability_radius_image_
used if ability own halo_image or overlay_image attributes in same time what [affect_adjacent].
t_string dismiss_message_
std::size_t max_ability_radius_
Used for easing checking if unit own a ability with [affect_adjacent] sub tag.
std::vector< t_string > trait_descriptions_
active_ability_list get_abilities_weapons(const std::string &tag_name, const_attack_ptr weapon=nullptr, const_attack_ptr opp_weapon=nullptr) const
unit_movement_resetter & operator=(const unit_movement_resetter &)=delete
@ version_1_16_or_older
Included some of the flavortext from weapon specials.
void set_big_profile(const std::string &value)
int max_hitpoints() const
The max number of hitpoints this unit can have.
void heal(int amount)
Heal the unit.
bool user_end_turn() const
Check whether the user ended their turn.
void set_role(const std::string &role)
Sets a unit's role.
unit_alignments::type alignment() const
The alignment of this unit.
void toggle_user_end_turn()
Toggle whether the user ended their turn.
bool incapacitated() const
Check if the unit has been petrified.
void set_state(const std::string &state, bool value)
Set whether the unit is affected by a status effect.
int level() const
The current level of this unit.
std::string usage() const
Gets this unit's usage.
const std::string & get_role() const
Gets this unit's role.
const t_string & type_name() const
Gets the translatable name of this unit's type.
const std::set< std::string > & recruits() const
The type IDs of the other units this unit may recruit, if possible.
void new_turn()
Refresh unit for the beginning of a turn.
void set_max_experience(int value)
void set_max_hitpoints(int value)
void set_hitpoints(int hp)
Sets the current hitpoint amount.
bool unrenamable() const
Whether this unit can be renamed.
const config & recall_filter() const
Gets the filter constraints upon which units this unit may recall, if able.
int recall_cost() const
How much gold it costs to recall this unit, or -1 if the side's default recall cost is used.
std::string big_profile() const
An optional profile image displays when this unit is 'speaking' via [message].
static state_t get_known_boolean_state_id(const std::string &state)
Convert a string status effect ID to a built-in status effect ID.
void set_level(int level)
Sets the current level of this unit.
void rename(const std::string &name)
Attempts to rename this unit's translatable display name, taking the 'unrenamable' flag into account.
void set_hidden(bool state) const
Sets whether the unit is hidden on the map.
void set_recall_filter(const config &filter)
Sets the filter constraints upon which units this unit may recall, if able.
const std::string & variation() const
The ID of the variation of this unit's type.
int hitpoints() const
The current number of hitpoints this unit has.
int cost() const
How much gold is required to recruit this unit.
bool hold_position() const
Whether the unit has been instructed to hold its position.
static std::string get_known_boolean_state_name(state_t state)
Convert a built-in status effect ID to a string status effect ID.
bool slowed() const
Check if the unit has been slowed.
bool get_state(const std::string &state) const
Check if the unit is affected by a status effect.
unsigned int experience_overflow() const
The number of experience points over max this unit has, or 0 if current XP < max XP.
std::string small_profile() const
An optional profile image to display in Help.
void heal_fully()
Fully heal the unit, restoring it to max hitpoints.
void set_undead_variation(const std::string &value)
The ID of the undead variation (ie, dwarf, swimmer) of this unit.
void toggle_hold_position()
Toggle the unit's hold position status.
const std::string & type_id() const
The id of this unit's type.
void set_alignment(unit_alignments::type alignment)
Sets the alignment of this unit.
bool get_hidden() const
Gets whether this unit is currently hidden on the map.
void set_name(const t_string &name)
Sets this unit's translatable display name.
void set_can_recruit(bool canrecruit)
Sets whether this unit can recruit other units.
const std::set< std::string > get_states() const
Get the status effects currently affecting the unit.
void set_side(unsigned int new_side)
Sets the side this unit belongs to.
void new_scenario()
Refresh unit for the beginning of a new scenario.
void end_turn()
Refresh unit for the end of a turn.
bool take_hit(int damage)
Damage the unit.
const config & variables() const
Const overload of variables.
const std::string & undead_variation() const
const unit_race * race() const
Gets this unit's race.
const unit_type & type() const
This unit's type, accounting for gender and variation.
int experience() const
The current number of experience points this unit has.
t_string block_dismiss_message() const
A message of why this unit cannot be dismissed.
bool can_recruit() const
Whether this unit can recruit other units - ie, are they a leader unit.
void set_experience(int xp)
Sets the current experience point amount.
void set_user_end_turn(bool value=true)
Set whether the user ended their turn.
const std::string & id() const
Gets this unit's id.
void set_underlying_id(n_unit::id_manager &id_manager)
Sets the internal ID.
int side() const
The side this unit belongs to.
bool dismissable() const
Whether this unit can be dismissed.
bool poisoned() const
Check if the unit has been poisoned.
unsigned int experience_to_advance() const
The number of experience points this unit needs to level up, or 0 if current XP > max XP.
state_t
Built-in status effects known to the engine.
double xp_bar_scaling() const
The factor by which the XP bar should be scaled.
void set_unit_description(const t_string &new_desc)
A detailed description of this unit.
void set_unrenamable(bool unrenamable)
Sets the 'unrenamable' flag.
void set_recruits(const std::vector< std::string > &recruits)
Sets the recruit list.
std::vector< t_string > unit_special_notes() const
The unit's special notes.
void set_id(const std::string &id)
Sets this unit's string ID.
config & variables()
Gets any user-defined variables this unit 'owns'.
void set_recall_cost(int recall_cost)
Sets the cost of recalling this unit.
std::size_t underlying_id() const
This unit's unique internal ID.
double hp_bar_scaling() const
The factor by which the HP bar should be scaled.
void set_usage(const std::string &usage)
Sets this unit's usage.
int max_experience() const
The max number of experience points this unit can have.
void set_small_profile(const std::string &value)
unit_race::GENDER gender() const
The gender of this unit.
const t_string & name() const
Gets this unit's translatable display name.
t_string unit_description() const
A detailed description of this unit.
@ STATE_UNKNOWN
To set the size of known_boolean_states_.
@ STATE_NOT_MOVED
The unit is uncovered - it was hiding but has been spotted.
@ STATE_GUARDIAN
The unit cannot be healed.
@ STATE_INVULNERABLE
The unit is a guardian - it won't move unless a target is sighted.
@ STATE_PETRIFIED
The unit is poisoned - it loses health each turn.
@ NUMBER_OF_STATES
The unit is invulnerable - it cannot be hit by any attack.
@ STATE_UNHEALABLE
The unit has not moved.
@ STATE_POISONED
The unit is slowed - it moves slower and does less damage.
@ STATE_UNCOVERED
The unit is petrified - it cannot move or be attacked.
std::vector< std::string > advances_to_t
std::vector< config > get_modification_advances() const
Gets any non-typed advanced options set by modifications.
std::vector< std::pair< std::string, std::string > > amla_icons() const
Gets the image and description data for modification advancements.
const advances_to_t & advances_to() const
Gets the possible types this unit can advance to on level-up.
bool can_advance() const
Checks whether this unit has any options to advance to.
bool advances() const
Checks whether this unit is eligible for level-up.
void set_advancements(std::vector< config > advancements)
Sets the raw modification advancement option data.
void set_advances_to(const std::vector< std::string > &advances_to)
Sets this unit's advancement options.
const std::vector< config > & modification_advancements() const
The raw, unparsed data for modification advancements.
std::map< std::string, std::string > advancement_icons() const
Gets and image path and and associated description for each advancement option.
const std::vector< std::string > advances_to_translated() const
Gets the names of the possible types this unit can advance to on level-up.
void advance_to(const unit_type &t, bool use_traits=false)
Advances this unit to another type.
void remove_attacks_ai()
Set the unit to have no attacks left for this turn.
attack_ptr add_attack(attack_itors::iterator position, Args &&... args)
Adds a new attack to the unit.
bool remove_attack(const attack_ptr &atk)
Remove an attack from the unit.
int resistance_against(const attack_type &atk, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr) const
The unit's resistance against a given attack.
void set_max_attacks(int value)
int attacks_left(bool base_value) const
Gets the remaining number of attacks this unit can perform this turn.
int resistance_value(active_ability_list resistance_list, const std::string &damage_name) const
For the provided list of resistance abilities, determine the damage resistance based on which are act...
int damage_from(const attack_type &attack, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr) const
Calculates the damage this unit would take from a certain attack.
int defense_modifier(const t_translation::terrain_code &terrain) const
bool resistance_filter_matches(const config &cfg, const std::string &damage_name, int res) const
attack_itors attacks()
Gets an iterator over this unit's attacks.
int defense_modifier(const t_translation::terrain_code &terrain, const map_location &loc) const
The unit's defense on a given terrain.
int resistance_against(const std::string &damage_name, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr, const const_attack_ptr &opp_weapon=nullptr) const
The unit's resistance against a given damage type.
utils::string_map_res get_base_resistances() const
Gets resistances without any abilities applied.
int max_attacks() const
The maximum number of attacks this unit may perform per turn, usually 1.
const_attack_itors attacks() const
Const overload of attacks.
int attacks_left() const
Gets the remaining number of attacks this unit can perform this turn.
void set_attacks(int left)
Sets the number of attacks this unit has left this turn.
color_t xp_color() const
Color for this unit's XP.
unit_animation_component & anim_comp() const
const std::string & effect_image_mods() const
Gets any IPF image mods applied by effects.
std::vector< std::string > overlays_abilities() const
Get the [overlay] ability overlay images.
color_t hp_color() const
Color for this unit's current hitpoints.
std::vector< std::string > halo_abilities() const
Get the [halo] abilities halo image(s).
std::string TC_image_mods() const
Constructs a recolor (RC) IPF string for this unit's team color.
static color_t hp_color_max()
const std::string & flag_rgb() const
Get the source color palette to use when recoloring the unit's image.
std::string image_ellipse() const
Get the unit's ellipse image.
std::string image_mods() const
Gets an IPF string containing all IPF image mods.
std::string default_anim_image() const
The default image to use for animation frames with no defined image.
std::string image_halo() const
Get the unit's halo image.
const std::vector< std::string > & overlays() const
Get the unit's overlay images.
std::string absolute_image() const
The name of the file to game_display (used in menus).
void set_image_ellipse(const std::string &ellipse)
Set the unit's ellipse image.
std::vector< std::string > halo_or_icon_abilities(const std::string &image_type) const
void set_image_halo(const std::string &halo)
Set the unit's halo image.
std::size_t advancements_count() const
std::size_t traits_count() const
void add_modification(const std::string &type, const config &modification, bool no_add=false)
Add a new modification to the unit.
static const std::set< std::string > builtin_effects
std::string describe_builtin_effect(const std::string &type, const config &effect)
Construct a string describing a built-in effect.
const config & get_modifications() const
Set the raw modifications.
config & get_modifications()
Get the raw modifications.
void apply_modifications()
Re-apply all saved modifications.
void expire_modifications(const std::string &duration)
Clears those modifications whose duration has expired.
std::size_t objects_count() const
void apply_builtin_effect(const std::string &type, const config &effect)
Apply a builtin effect to the unit.
std::size_t modification_count(const std::string &type, const std::string &id) const
Count modifications of a particular type.
bool emits_zoc() const
Tests whether the unit has a zone-of-control, considering incapacitated.
bool get_emit_zoc() const
Gets the raw zone-of-control flag, disregarding incapacitated.
int jamming() const
Gets the unit's jamming points.
bool has_goto() const
Gets whether this unit has a multi-turn destination set.
const map_location & get_location() const
The current map location this unit is at.
bool has_moved() const
Checks if this unit has moved.
int movement_cost(const t_translation::terrain_code &terrain) const
Get the unit's movement cost on a particular terrain.
const movetype & movement_type() const
Get the unit's movement type.
void set_movement(int moves, bool unit_action=false)
Set this unit's remaining movement to moves.
const map_location & get_interrupted_move() const
Get the target location of the unit's interrupted move.
int vision_cost(const t_translation::terrain_code &terrain) const
Get the unit's vision cost on a particular terrain.
void set_resting(bool rest)
Sets this unit's resting status.
void set_facing(map_location::direction dir) const
The this unit's facing.
void set_total_movement(int value)
void set_emit_zoc(bool val)
Sets the raw zone-of-control flag.
void set_goto(const map_location &new_goto)
Sets this unit's long term destination.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
int movement_left(bool base_value) const
Gets how far a unit can move.
int total_movement() const
The maximum moves this unit has.
int jamming_cost(const t_translation::terrain_code &terrain) const
Get the unit's jamming cost on a particular terrain.
void set_location(const map_location &loc)
Sets this unit's map location.
void remove_movement_ai()
Sets the unit to have no moves left for this turn.
bool move_interrupted() const
Check whether the unit's move has been interrupted.
int vision() const
Gets the unit's vision points.
const map_location & get_goto() const
The map location to which this unit is moving over multiple turns, if any.
map_location::direction facing() const
The current direction this unit is facing within its hex.
bool resting() const
Checks whether this unit is 'resting'.
void set_interrupted_move(const map_location &interrupted_move)
Set the target location of the unit's interrupted move.
bool is_flying() const
Check if the unit is a flying unit.
std::vector< std::string > get_advancements_list() const
std::vector< std::string > get_objects_list() const
std::vector< std::string > get_modifications_list(const std::string &mod_type) const
Gets a list of the modification this unit currently has.
int upkeep() const
Gets the amount of gold this unit costs a side per turn.
std::vector< std::string > trait_nonhidden_ids() const
Gets the ids of the traits corresponding to those returned by trait_names() and trait_descriptions().
std::size_t max_ability_radius_type(const std::string &tag_name) const
If this unit has abilities of tag_name type with [affect_adjacent] subtags, returns the radius of the...
void add_trait_description(const config &trait, const t_string &description)
Register a trait's name and its description for the UI's use.
bool is_healthy() const
Gets whether this unit is healthy - ie, always rest heals.
bool is_fearless() const
Gets whether this unit is fearless - ie, unaffected by time of day.
std::size_t max_ability_radius_image() const
If this unit has abilities with [affect_adjacent] subtags and halo_image or overlay_image attributes,...
utils::variant< upkeep_full, upkeep_loyal, int > upkeep_t
const std::vector< t_string > & trait_descriptions() const
Gets the descriptions of the currently registered traits.
std::vector< std::string > get_traits_list() const
Gets a list of the traits this unit currently has, including hidden traits.
const std::vector< t_string > & trait_names() const
Gets the names of the currently registered traits.
void generate_traits(bool must_have_only=false)
Applies mandatory traits (e.g.
std::size_t max_ability_radius() const
If this unit has abilities with [affect_adjacent] subtags, returns the radius of the one with the fur...
upkeep_t upkeep_raw() const
Gets the raw variant controlling the upkeep value.
void set_loyal(bool loyal)
bool loyal() const
Gets whether this unit is loyal - ie, it costs no upkeep.
void set_upkeep(upkeep_t v)
Sets the upkeep value to a specific value value.
std::string tag(std::string_view tag, Args &&... data)
Wraps the given data in the specified tag.
std::map< std::string, t_string, res_compare > string_map_res
std::map< std::string, t_string > string_map
std::string::const_iterator iterator
std::shared_ptr< const unit_ability_t > const_ability_ptr
std::shared_ptr< const attack_type > const_attack_ptr
std::shared_ptr< unit_ability_t > ability_ptr
std::shared_ptr< attack_type > attack_ptr
std::shared_ptr< unit > unit_ptr
Data typedef for active_ability_list.
active_ability(const ability_ptr &p_ability, map_location student_loc, map_location teacher_loc)
const config & ability_cfg() const
map_location teacher_loc
The location of the teacher, that is the unit who owns the ability tags (different from student becau...
const unit_ability_t & ability() const
const_ability_ptr p_ability_
The contents of the ability tag, never nullptr.
map_location student_loc
Used by the formula in the ability.
The basic class for representing 8-bit RGB or RGBA colour values.
Encapsulates the map of the game.
direction
Valid directions which can be moved in our hexagonal world.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
Visitor helper struct to fetch the upkeep type flag if applicable, or the the value otherwise.
Object which temporarily resets a unit's movement.
static map_location::direction n
static map_location::direction s
std::string get_checksum(const unit &u, backwards_compatibility::unit_checksum_version version=backwards_compatibility::unit_checksum_version::current)
Gets a checksum for a unit.
MacOS doesn't support std::visit when targing MacOS < 10.14 (currently we target 10....