The Battle for Wesnoth  1.19.1+dev
Classes | Public Member Functions | Private Types | Private Attributes | Friends | List of all members
attack_type Class Reference

#include <attack_type.hpp>

Inheritance diagram for attack_type:

Classes

class  specials_context_t
 

Public Member Functions

 attack_type (const config &cfg)
 
const t_stringname () const
 
const std::string & id () const
 
const std::string & type () const
 
const std::string & icon () const
 
const std::string & range () const
 
int min_range () const
 
int max_range () const
 
std::string accuracy_parry_description () const
 
int accuracy () const
 
int parry () const
 
int damage () const
 
int num_attacks () const
 
double attack_weight () const
 
double defense_weight () const
 
const configspecials () const
 
void set_name (const t_string &value)
 
void set_id (const std::string &value)
 
void set_type (const std::string &value)
 
void set_icon (const std::string &value)
 
void set_range (const std::string &value)
 
void set_accuracy (int value)
 
void set_parry (int value)
 
void set_damage (int value)
 
void set_num_attacks (int value)
 
void set_attack_weight (double value)
 
void set_defense_weight (double value)
 
void set_specials (config value)
 
bool has_special (const std::string &special, bool simple_check=false, bool special_id=true, bool special_tags=true) const
 Returns whether or not *this has a special with a tag or id equal to special. More...
 
unit_ability_list get_specials (const std::string &special) const
 Returns the currently active specials as an ability list, given the current context (see set_specials_context). More...
 
std::vector< std::pair< t_string, t_string > > special_tooltips (boost::dynamic_bitset<> *active_list=nullptr) const
 Returns a vector of names and descriptions for the specials of *this. More...
 
bool matches_filter (const config &filter, const std::string &tag_name="") const
 Returns whether or not *this matches the given filter. More...
 
bool apply_modification (const config &cfg)
 Modifies *this using the specifications in cfg, but only if *this matches cfg viewed as a filter. More...
 
bool describe_modification (const config &cfg, std::string *description)
 Trimmed down version of apply_modification(), with no modifications actually made. More...
 
int movement_used () const
 
void set_movement_used (int value)
 
int attacks_used () const
 
void set_attacks_used (int value)
 
void write (config &cfg) const
 
config to_config () const
 
void add_formula_context (wfl::map_formula_callable &) const
 
specials_context_t specials_context (unit_const_ptr self, unit_const_ptr other, const map_location &unit_loc, const map_location &other_loc, bool attacking, const_attack_ptr other_attack) const
 
specials_context_t specials_context (unit_const_ptr self, const map_location &loc, bool attacking=true) const
 
specials_context_t specials_context (const unit_type &self_type, const map_location &loc, bool attacking=true) const
 
specials_context_t specials_context_for_listing (bool attacking=true) const
 
void set_changed (bool value)
 
bool get_changed () const
 

Private Types

enum  AFFECTS { AFFECT_SELF =1 , AFFECT_OTHER =2 , AFFECT_EITHER =3 }
 

Private Attributes

map_location self_loc_
 
map_location other_loc_
 
unit_const_ptr self_
 
unit_const_ptr other_
 
bool is_attacker_
 
const_attack_ptr other_attack_
 
bool is_for_listing_ = false
 
t_string description_
 
std::string id_
 
std::string type_
 
std::string icon_
 
std::string range_
 
int min_range_
 
int max_range_
 
int damage_
 
int num_attacks_
 
double attack_weight_
 
double defense_weight_
 
int accuracy_
 
int movement_used_
 
int attacks_used_
 
int parry_
 
config specials_
 
bool changed_
 

Friends

class specials_context_t
 

already added

std::string weapon_specials () const
 Returns a comma-separated string of active names for the specials of *this. More...
 
std::string weapon_specials_value (const std::set< std::string > checking_tags) const
 
void modified_attacks (unsigned &min_attacks, unsigned &max_attacks) const
 Calculates the number of attacks this weapon has, considering specials. More...
 
std::string select_damage_type (const unit_ability_list &damage_type_list, const std::string &key_name, unit_ability_list resistance_list) const
 Select best damage type based on frequency count for replacement_type and based on highest damage for alternative_type. More...
 
std::pair< std::string, std::string > damage_type () const
 return a modified damage type and/or add a secondary_type for hybrid use if special is active. More...
 
std::set< std::string > alternative_damage_types () const
 
int modified_damage () const
 Returns the damage per attack of this weapon, considering specials. More...
 
int composite_value (const unit_ability_list &abil_list, int base_value) const
 Return the special weapon value, considering specials. More...
 
unit_ability_list get_weapon_ability (const std::string &ability) const
 Returns list for weapon like abilities for each ability type. More...
 
unit_ability_list get_specials_and_abilities (const std::string &special) const
 
bool has_weapon_ability (const std::string &special, bool special_id=true, bool special_tags=true) const
 used for abilities used like weapon More...
 
bool has_special_or_ability (const std::string &special, bool special_id=true, bool special_tags=true) const
 used for abilities used like weapon and true specials More...
 
unit_ability_list overwrite_special_overwriter (unit_ability_list overwriters, const std::string &tag_name) const
 Filter a list of abilities or weapon specials, removing any entries that don't own the overwrite_specials attributes. More...
 
bool overwrite_special_checking (unit_ability_list &overwriters, const config &cfg, const std::string &tag_name) const
 Check whether cfg would be overwritten by any element of overwriters. More...
 
bool check_self_abilities (const config &cfg, const std::string &special) const
 check_self_abilities : return an boolean value for checking of activities of abilities used like weapon More...
 
bool check_adj_abilities (const config &cfg, const std::string &special, int dir, const unit &from) const
 check_adj_abilities : return an boolean value for checking of activities of abilities used like weapon More...
 
bool special_active (const config &special, AFFECTS whom, const std::string &tag_name, const std::string &filter_self="filter_self") const
 
static void weapon_specials_impl_self (std::string &temp_string, unit_const_ptr self, const_attack_ptr self_attack, const_attack_ptr other_attack, const map_location &self_loc, AFFECTS whom, std::set< std::string > &checking_name, const std::set< std::string > &checking_tags={}, bool leader_bool=false)
 weapon_specials_impl_self and weapon_specials_impl_adj : check if special name can be added. More...
 
static void weapon_specials_impl_adj (std::string &temp_string, unit_const_ptr self, const_attack_ptr self_attack, const_attack_ptr other_attack, const map_location &self_loc, AFFECTS whom, std::set< std::string > &checking_name, const std::set< std::string > &checking_tags={}, const std::string &affect_adjacents="", bool leader_bool=false)
 
static bool check_self_abilities_impl (const_attack_ptr self_attack, const_attack_ptr other_attack, const config &special, unit_const_ptr u, const map_location &loc, AFFECTS whom, const std::string &tag_name, bool leader_bool=false)
 check_self_abilities_impl : return an boolean value for checking of activities of abilities used like weapon More...
 
static bool check_adj_abilities_impl (const_attack_ptr self_attack, const_attack_ptr other_attack, const config &special, unit_const_ptr u, const unit &from, int dir, const map_location &loc, AFFECTS whom, const std::string &tag_name, bool leader_bool=false)
 check_adj_abilities_impl : return an boolean value for checking of activities of abilities used like weapon in unit adjacent to fighter More...
 
static bool special_active_impl (const_attack_ptr self_attack, const_attack_ptr other_attack, const config &special, AFFECTS whom, const std::string &tag_name, const std::string &filter_self="filter_self")
 Returns whether or not the given special is active for the specified unit, based on the current context (see set_specials_context). More...
 

Detailed Description

Definition at line 36 of file attack_type.hpp.

Member Enumeration Documentation

◆ AFFECTS

enum attack_type::AFFECTS
private
Enumerator
AFFECT_SELF 
AFFECT_OTHER 
AFFECT_EITHER 

Definition at line 152 of file attack_type.hpp.

Constructor & Destructor Documentation

◆ attack_type()

attack_type::attack_type ( const config cfg)
explicit

Definition at line 49 of file attack_type.cpp.

References description_, translation::egettext(), t_string::empty(), icon_, and id_.

Member Function Documentation

◆ accuracy()

int attack_type::accuracy ( ) const
inline

Definition at line 49 of file attack_type.hpp.

References accuracy_.

Referenced by impl_unit_attack_get(), and matches_simple_filter().

◆ accuracy_parry_description()

std::string attack_type::accuracy_parry_description ( ) const

Definition at line 83 of file attack_type.cpp.

References accuracy_, parry_, s, and utils::signed_percent().

◆ add_formula_context()

void attack_type::add_formula_context ( wfl::map_formula_callable callable) const

Definition at line 527 of file abilities.cpp.

References wfl::map_formula_callable::add(), is_attacker_, other_, and self_.

◆ alternative_damage_types()

std::set< std::string > attack_type::alternative_damage_types ( ) const
Returns
A list of alternative_type damage types.

Definition at line 1262 of file abilities.cpp.

References c, unit_ability_list::empty(), get_specials_and_abilities(), and i.

◆ apply_modification()

bool attack_type::apply_modification ( const config cfg)

◆ attack_weight()

double attack_type::attack_weight ( ) const
inline

Definition at line 53 of file attack_type.hpp.

References attack_weight_.

Referenced by battle_context::choose_attacker_weapon(), and impl_unit_attack_get().

◆ attacks_used()

int attack_type::attacks_used ( ) const
inline

Definition at line 141 of file attack_type.hpp.

References attacks_used_.

Referenced by impl_unit_attack_get(), and matches_simple_filter().

◆ check_adj_abilities()

bool attack_type::check_adj_abilities ( const config cfg,
const std::string &  special,
int  dir,
const unit from 
) const
private

check_adj_abilities : return an boolean value for checking of activities of abilities used like weapon

Returns
True if the special special is active.
Parameters
cfgthe config to one special ability checked.
specialThe special ability type who is being checked.
dirdirection to research a unit adjacent to self_.
fromunit adjacent to self_ is checked.

Definition at line 1605 of file abilities.cpp.

References AFFECT_SELF, check_adj_abilities_impl(), other_attack_, self_, and self_loc_.

Referenced by has_weapon_ability().

◆ check_adj_abilities_impl()

bool attack_type::check_adj_abilities_impl ( const_attack_ptr  self_attack,
const_attack_ptr  other_attack,
const config special,
unit_const_ptr  u,
const unit from,
int  dir,
const map_location loc,
AFFECTS  whom,
const std::string &  tag_name,
bool  leader_bool = false 
)
staticprivate

check_adj_abilities_impl : return an boolean value for checking of activities of abilities used like weapon in unit adjacent to fighter

Returns
True if the special tag_name is active.
Parameters
self_attackthe attack used by unit who fight.
other_attackthe attack used by opponent.
specialthe config to one special ability checked.
uthe unit who is or not affected by an abilities owned by from.
fromunit adjacent to u is checked.
dirdirection to research a unit adjacent to u.
loclocation of the unit checked.
whomdetermine if unit affected or not by special ability.
tag_nameThe special ability type who is being checked.
leader_boolIf true, [leadership] abilities are checked.

Definition at line 1610 of file abilities.cpp.

References special_active_impl().

Referenced by check_adj_abilities(), has_weapon_ability(), and weapon_specials_impl_adj().

◆ check_self_abilities()

bool attack_type::check_self_abilities ( const config cfg,
const std::string &  special 
) const
private

check_self_abilities : return an boolean value for checking of activities of abilities used like weapon

Returns
True if the special special is active.
Parameters
cfgthe config to one special ability checked.
specialThe special ability type who is being checked.

Definition at line 1585 of file abilities.cpp.

References AFFECT_SELF, check_self_abilities_impl(), other_attack_, self_, and self_loc_.

Referenced by has_weapon_ability().

◆ check_self_abilities_impl()

bool attack_type::check_self_abilities_impl ( const_attack_ptr  self_attack,
const_attack_ptr  other_attack,
const config special,
unit_const_ptr  u,
const map_location loc,
AFFECTS  whom,
const std::string &  tag_name,
bool  leader_bool = false 
)
staticprivate

check_self_abilities_impl : return an boolean value for checking of activities of abilities used like weapon

Returns
True if the special tag_name is active.
Parameters
self_attackthe attack used by unit checked in this function.
other_attackthe attack used by opponent to unit checked.
specialthe config to one special ability checked.
uthe unit checked.
loclocation of the unit checked.
whomdetermine if unit affected or not by special ability.
tag_nameThe special ability type who is being checked.
leader_boolIf true, [leadership] abilities are checked.

Definition at line 1590 of file abilities.cpp.

References special_active_impl().

Referenced by check_self_abilities(), has_weapon_ability(), and weapon_specials_impl_self().

◆ composite_value()

int attack_type::composite_value ( const unit_ability_list abil_list,
int  base_value 
) const

Return the special weapon value, considering specials.

Parameters
abil_listThe list of special checked.
base_valueThe value modified or not by function.

Definition at line 1439 of file abilities.cpp.

References unit_abilities::effect::get_composite_value().

Referenced by modified_attacks(), and modified_damage().

◆ damage()

int attack_type::damage ( ) const
inline

◆ damage_type()

std::pair< std::string, std::string > attack_type::damage_type ( ) const

return a modified damage type and/or add a secondary_type for hybrid use if special is active.

Returns the type of damage inflicted.

Definition at line 1242 of file abilities.cpp.

References unit_ability_list::empty(), get_specials_and_abilities(), other_, other_attack_, other_loc_, select_damage_type(), and type().

Referenced by matches_simple_filter(), and gui2::dialogs::unit_attack::pre_show().

◆ defense_weight()

double attack_type::defense_weight ( ) const
inline

Definition at line 54 of file attack_type.hpp.

References defense_weight_.

Referenced by battle_context::choose_defender_weapon(), and impl_unit_attack_get().

◆ describe_modification()

bool attack_type::describe_modification ( const config cfg,
std::string *  description 
)

Trimmed down version of apply_modification(), with no modifications actually made.

This can be used to get a description of the modification(s) specified by cfg (if *this matches cfg as a filter).

If *description is provided, it will be set to a (translated) description of the modification(s) applied (currently only changes to the number of strikes, damage, accuracy, and parry are included in this description).

Returns
whether or not this matched the cfg as a filter.

Definition at line 447 of file attack_type.cpp.

References utils::format_conjunct_list(), matches_filter(), utils::print_modifier(), set_accuracy(), set_attacks_used(), set_damage(), set_parry(), VGETTEXT, and VNGETTEXT.

◆ get_changed()

bool attack_type::get_changed ( ) const
inline

Definition at line 331 of file attack_type.hpp.

References changed_.

◆ get_specials()

unit_ability_list attack_type::get_specials ( const std::string &  special) const

Returns the currently active specials as an ability list, given the current context (see set_specials_context).

Definition at line 824 of file abilities.cpp.

References AFFECT_OTHER, AFFECT_SELF, config::child_range(), unit_ability_list::emplace_back(), i, other_attack_, other_loc_, self_, self_loc_, special_active(), and specials_.

Referenced by get_specials_and_abilities().

◆ get_specials_and_abilities()

unit_ability_list attack_type::get_specials_and_abilities ( const std::string &  special) const
Parameters
specialthe tag name to check for
Returns
list which contains get_weapon_ability and get_specials list for each ability type, with overwritten items removed

Definition at line 1422 of file abilities.cpp.

References unit_ability::ability_cfg, unit_ability_list::append(), unit_ability_list::empty(), utils::erase_if(), get_specials(), get_weapon_ability(), overwrite_special_checking(), and overwrite_special_overwriter().

Referenced by alternative_damage_types(), damage_type(), modified_attacks(), and modified_damage().

◆ get_weapon_ability()

unit_ability_list attack_type::get_weapon_ability ( const std::string &  ability) const

Returns list for weapon like abilities for each ability type.

Definition at line 1403 of file abilities.cpp.

References unit_ability_list::append_if(), i, other_, other_loc_, self_, and self_loc_.

Referenced by get_specials_and_abilities().

◆ has_special()

bool attack_type::has_special ( const std::string &  special,
bool  simple_check = false,
bool  special_id = true,
bool  special_tags = true 
) const

Returns whether or not *this has a special with a tag or id equal to special.

Returns
True iff the special special is active.
Parameters
specialThe special being checked.
simple_checkIf true, check whether the unit has the special. Else, check whether the special is currently active.
special_idIf true, match special against the id of special tags.
special_tagsIf true, match special against the tag name of special tags.

If simple_check is set to true, then the check is merely for being present. Otherwise (the default), the check is for a special active in the current context (see set_specials_context), including specials obtained from the opponent's attack.

Definition at line 752 of file abilities.cpp.

References AFFECT_OTHER, AFFECT_SELF, other_attack_, special_active(), and specials_.

Referenced by has_special_or_ability(), and matches_simple_filter().

◆ has_special_or_ability()

bool attack_type::has_special_or_ability ( const std::string &  special,
bool  special_id = true,
bool  special_tags = true 
) const

used for abilities used like weapon and true specials

Returns
True if the ability special is active.
Parameters
specialThe special being checked.
special_idIf true, match special against the id of special tags.
special_tagsIf true, match special against the tag name of special tags.

Definition at line 1731 of file abilities.cpp.

References has_special(), has_weapon_ability(), and range().

Referenced by matches_simple_filter().

◆ has_weapon_ability()

bool attack_type::has_weapon_ability ( const std::string &  special,
bool  special_id = true,
bool  special_tags = true 
) const

used for abilities used like weapon

Returns whether or not *this has a special ability with a tag or id equal to special.

Returns
True if the ability special is active.
Parameters
specialThe special being checked.
special_idIf true, match special against the id of special tags.
special_tagsIf true, match special against the tag name of special tags.

the Check is for a special ability active in the current context (see set_specials_context), including specials obtained from the opponent's attack.

Definition at line 1630 of file abilities.cpp.

References AFFECT_OTHER, check_adj_abilities(), check_adj_abilities_impl(), check_self_abilities(), check_self_abilities_impl(), unit_map::end(), unit_map::find(), get_ability_children(), get_adjacent_tiles(), i, other_, other_attack_, other_loc_, self_, and self_loc_.

Referenced by has_special_or_ability().

◆ icon()

const std::string& attack_type::icon ( ) const
inline

Definition at line 44 of file attack_type.hpp.

References icon_.

Referenced by impl_unit_attack_get(), and gui2::dialogs::unit_attack::pre_show().

◆ id()

const std::string& attack_type::id ( ) const
inline

Definition at line 42 of file attack_type.hpp.

References id_.

Referenced by impl_unit_attack_get(), and matches_simple_filter().

◆ matches_filter()

bool attack_type::matches_filter ( const config filter,
const std::string &  tag_name = "" 
) const

Returns whether or not *this matches the given filter.

Definition at line 259 of file attack_type.cpp.

References config::all_children_range(), and matches_simple_filter().

Referenced by apply_modification(), and describe_modification().

◆ max_range()

int attack_type::max_range ( ) const
inline

Definition at line 47 of file attack_type.hpp.

References max_range_.

◆ min_range()

int attack_type::min_range ( ) const
inline

Definition at line 46 of file attack_type.hpp.

References min_range_.

◆ modified_attacks()

void attack_type::modified_attacks ( unsigned &  min_attacks,
unsigned &  max_attacks 
) const

Calculates the number of attacks this weapon has, considering specials.

This returns two numbers because of the swarm special. The actual number of attacks depends on the unit's health and should be: min_attacks + (max_attacks - min_attacks) * (current hp) / (max hp) c.f. swarm_blows()

Definition at line 1150 of file abilities.cpp.

References composite_value(), unit_ability_list::empty(), ERR_NG, get_specials_and_abilities(), unit_ability_list::highest(), and num_attacks().

◆ modified_damage()

int attack_type::modified_damage ( ) const

Returns the damage per attack of this weapon, considering specials.

Definition at line 1283 of file abilities.cpp.

References composite_value(), damage(), and get_specials_and_abilities().

◆ movement_used()

int attack_type::movement_used ( ) const
inline

Definition at line 139 of file attack_type.hpp.

References movement_used_.

Referenced by impl_unit_attack_get(), and matches_simple_filter().

◆ name()

const t_string& attack_type::name ( ) const
inline

◆ num_attacks()

int attack_type::num_attacks ( ) const
inline

◆ overwrite_special_checking()

bool attack_type::overwrite_special_checking ( unit_ability_list overwriters,
const config cfg,
const std::string &  tag_name 
) const
private

Check whether cfg would be overwritten by any element of overwriters.

Returns
True if element checked is overwritable.
Parameters
overwriterslist used for check if element is overwritable.
cfgelement checked.
tag_nametype of abilitie/special checked.

Definition at line 1486 of file abilities.cpp.

References unit_ability_list::empty(), is_attacker_, config::optional_child(), overwrite_special_affects(), and self_.

Referenced by get_specials_and_abilities(), and overwrite_special_overwriter().

◆ overwrite_special_overwriter()

unit_ability_list attack_type::overwrite_special_overwriter ( unit_ability_list  overwriters,
const std::string &  tag_name 
) const
private

Filter a list of abilities or weapon specials, removing any entries that don't own the overwrite_specials attributes.

Parameters
overwriterslist that may have overwrite_specials attributes.
tag_nametype of abilitie/special checked.

Definition at line 1450 of file abilities.cpp.

References unit_ability::ability_cfg, unit_ability_list::empty(), utils::erase_if(), i, overwrite_special_affects(), overwrite_special_checking(), unit_ability_list::size(), and utils::sort_if().

Referenced by get_specials_and_abilities().

◆ parry()

int attack_type::parry ( ) const
inline

Definition at line 50 of file attack_type.hpp.

References parry_.

Referenced by impl_unit_attack_get(), and matches_simple_filter().

◆ range()

const std::string& attack_type::range ( ) const
inline

◆ select_damage_type()

std::string attack_type::select_damage_type ( const unit_ability_list damage_type_list,
const std::string &  key_name,
unit_ability_list  resistance_list 
) const

Select best damage type based on frequency count for replacement_type and based on highest damage for alternative_type.

Parameters
damage_type_listlist of [damage_type] to check.
key_namename of attribute checked 'alternative_type' or 'replacement_type'.
resistance_listlist of "resistance" abilities to check for each type of damage checked.

Definition at line 1228 of file abilities.cpp.

References other_, select_alternative_type(), and select_replacement_type().

Referenced by damage_type().

◆ set_accuracy()

void attack_type::set_accuracy ( int  value)
inline

Definition at line 62 of file attack_type.hpp.

References accuracy_, and set_changed().

Referenced by apply_modification(), describe_modification(), and impl_unit_attack_set().

◆ set_attack_weight()

void attack_type::set_attack_weight ( double  value)
inline

Definition at line 66 of file attack_type.hpp.

References attack_weight_, and set_changed().

Referenced by apply_modification(), and impl_unit_attack_set().

◆ set_attacks_used()

void attack_type::set_attacks_used ( int  value)
inline

Definition at line 142 of file attack_type.hpp.

References attacks_used_.

Referenced by apply_modification(), describe_modification(), and impl_unit_attack_set().

◆ set_changed()

void attack_type::set_changed ( bool  value)
inline

◆ set_damage()

void attack_type::set_damage ( int  value)
inline

Definition at line 64 of file attack_type.hpp.

References damage_, and set_changed().

Referenced by apply_modification(), describe_modification(), and impl_unit_attack_set().

◆ set_defense_weight()

void attack_type::set_defense_weight ( double  value)
inline

Definition at line 67 of file attack_type.hpp.

References defense_weight_, and set_changed().

Referenced by apply_modification(), and impl_unit_attack_set().

◆ set_icon()

void attack_type::set_icon ( const std::string &  value)
inline

Definition at line 60 of file attack_type.hpp.

References icon_, and set_changed().

Referenced by apply_modification(), and impl_unit_attack_set().

◆ set_id()

void attack_type::set_id ( const std::string &  value)
inline

Definition at line 58 of file attack_type.hpp.

References id_, and set_changed().

Referenced by impl_unit_attack_set().

◆ set_movement_used()

void attack_type::set_movement_used ( int  value)
inline

Definition at line 140 of file attack_type.hpp.

References movement_used_.

Referenced by impl_unit_attack_set().

◆ set_name()

void attack_type::set_name ( const t_string value)
inline

Definition at line 57 of file attack_type.hpp.

References description_, and set_changed().

Referenced by apply_modification(), and impl_unit_attack_set().

◆ set_num_attacks()

void attack_type::set_num_attacks ( int  value)
inline

Definition at line 65 of file attack_type.hpp.

References num_attacks_, and set_changed().

Referenced by impl_unit_attack_set().

◆ set_parry()

void attack_type::set_parry ( int  value)
inline

Definition at line 63 of file attack_type.hpp.

References parry_, and set_changed().

Referenced by apply_modification(), describe_modification(), and impl_unit_attack_set().

◆ set_range()

void attack_type::set_range ( const std::string &  value)
inline

Definition at line 61 of file attack_type.hpp.

References range_, and set_changed().

Referenced by apply_modification(), and impl_unit_attack_set().

◆ set_specials()

void attack_type::set_specials ( config  value)
inline

Definition at line 68 of file attack_type.hpp.

References set_changed(), and specials_.

Referenced by apply_modification(), and impl_unit_attack_set().

◆ set_type()

void attack_type::set_type ( const std::string &  value)
inline

Definition at line 59 of file attack_type.hpp.

References set_changed(), and type_.

Referenced by apply_modification(), and impl_unit_attack_set().

◆ special_active()

bool attack_type::special_active ( const config special,
AFFECTS  whom,
const std::string &  tag_name,
const std::string &  filter_self = "filter_self" 
) const
private

◆ special_active_impl()

bool attack_type::special_active_impl ( const_attack_ptr  self_attack,
const_attack_ptr  other_attack,
const config special,
AFFECTS  whom,
const std::string &  tag_name,
const std::string &  filter_self = "filter_self" 
)
staticprivate

◆ special_tooltips()

std::vector< std::pair< t_string, t_string > > attack_type::special_tooltips ( boost::dynamic_bitset<> *  active_list = nullptr) const

Returns a vector of names and descriptions for the specials of *this.

Each std::pair in the vector has first = name and second = description.

This uses either the active or inactive name/description for each special, based on the current context (see set_specials_context), provided active_list is not nullptr. Otherwise specials are assumed active. If the appropriate name is empty, the special is skipped.

Definition at line 857 of file abilities.cpp.

References AFFECT_EITHER, config::all_children_range(), t_string::empty(), name(), special_active(), and specials_.

◆ specials()

const config& attack_type::specials ( ) const
inline

Definition at line 55 of file attack_type.hpp.

References specials_.

Referenced by impl_unit_attack_get().

◆ specials_context() [1/3]

specials_context_t attack_type::specials_context ( const unit_type self_type,
const map_location loc,
bool  attacking = true 
) const
inline

Definition at line 321 of file attack_type.hpp.

References specials_context_t.

◆ specials_context() [2/3]

specials_context_t attack_type::specials_context ( unit_const_ptr  self,
const map_location loc,
bool  attacking = true 
) const
inline

Definition at line 318 of file attack_type.hpp.

References specials_context_t.

◆ specials_context() [3/3]

specials_context_t attack_type::specials_context ( unit_const_ptr  self,
unit_const_ptr  other,
const map_location unit_loc,
const map_location other_loc,
bool  attacking,
const_attack_ptr  other_attack 
) const
inline

◆ specials_context_for_listing()

specials_context_t attack_type::specials_context_for_listing ( bool  attacking = true) const
inline

Definition at line 324 of file attack_type.hpp.

References specials_context_t.

◆ to_config()

config attack_type::to_config ( ) const
inline

Definition at line 145 of file attack_type.hpp.

References c, and write().

Referenced by impl_unit_attack_get().

◆ type()

const std::string& attack_type::type ( ) const
inline

◆ weapon_specials()

std::string attack_type::weapon_specials ( ) const

Returns a comma-separated string of active names for the specials of *this.

Empty names are skipped.

Whether or not a special is active depends on the current context (see set_specials_context)

Definition at line 911 of file abilities.cpp.

References AFFECT_EITHER, AFFECT_SELF, config::all_children_range(), t_string::empty(), font::inactive_details_color, name(), other_attack_, self_, self_loc_, font::span_color(), special_active(), specials_, weapon_specials_impl_adj(), and weapon_specials_impl_self().

Referenced by gui2::dialogs::unit_attack::pre_show().

◆ weapon_specials_impl_adj()

void attack_type::weapon_specials_impl_adj ( std::string &  temp_string,
unit_const_ptr  self,
const_attack_ptr  self_attack,
const_attack_ptr  other_attack,
const map_location self_loc,
AFFECTS  whom,
std::set< std::string > &  checking_name,
const std::set< std::string > &  checking_tags = {},
const std::string &  affect_adjacents = "",
bool  leader_bool = false 
)
staticprivate

◆ weapon_specials_impl_self()

void attack_type::weapon_specials_impl_self ( std::string &  temp_string,
unit_const_ptr  self,
const_attack_ptr  self_attack,
const_attack_ptr  other_attack,
const map_location self_loc,
AFFECTS  whom,
std::set< std::string > &  checking_name,
const std::set< std::string > &  checking_tags = {},
bool  leader_bool = false 
)
staticprivate

weapon_specials_impl_self and weapon_specials_impl_adj : check if special name can be added.

Parameters
[in,out]temp_stringthe string modified and returned
[in]selfthe unit checked.
[in]self_attackthe attack used by unit checked in this function.
[in]other_attackthe attack used by opponent to unit checked.
[in]self_loclocation of the unit checked.
[in]whomdetermine if unit affected or not by special ability.
[in,out]checking_namethe reference for checking if a name is already added
[in]checking_tagsthe reference for checking if special ability type can be used
[in]leader_boolIf true, [leadership] abilities are checked.

Definition at line 994 of file abilities.cpp.

References add_name(), and check_self_abilities_impl().

Referenced by weapon_specials(), and weapon_specials_value().

◆ weapon_specials_value()

std::string attack_type::weapon_specials_value ( const std::set< std::string >  checking_tags) const

◆ write()

void attack_type::write ( config cfg) const

Friends And Related Function Documentation

◆ specials_context_t

friend class specials_context_t
friend

Definition at line 282 of file attack_type.hpp.

Referenced by specials_context(), and specials_context_for_listing().

Member Data Documentation

◆ accuracy_

int attack_type::accuracy_
private

◆ attack_weight_

double attack_type::attack_weight_
private

Definition at line 345 of file attack_type.hpp.

Referenced by apply_modification(), attack_weight(), set_attack_weight(), and write().

◆ attacks_used_

int attack_type::attacks_used_
private

Definition at line 350 of file attack_type.hpp.

Referenced by apply_modification(), attacks_used(), set_attacks_used(), and write().

◆ changed_

bool attack_type::changed_
private

Definition at line 353 of file attack_type.hpp.

Referenced by get_changed(), and set_changed().

◆ damage_

int attack_type::damage_
private

Definition at line 343 of file attack_type.hpp.

Referenced by apply_modification(), damage(), set_damage(), and write().

◆ defense_weight_

double attack_type::defense_weight_
private

Definition at line 346 of file attack_type.hpp.

Referenced by apply_modification(), defense_weight(), set_defense_weight(), and write().

◆ description_

t_string attack_type::description_
private

Definition at line 337 of file attack_type.hpp.

Referenced by apply_modification(), attack_type(), name(), set_name(), and write().

◆ icon_

std::string attack_type::icon_
private

Definition at line 340 of file attack_type.hpp.

Referenced by apply_modification(), attack_type(), icon(), set_icon(), and write().

◆ id_

std::string attack_type::id_
private

Definition at line 338 of file attack_type.hpp.

Referenced by apply_modification(), attack_type(), id(), set_id(), and write().

◆ is_attacker_

bool attack_type::is_attacker_
mutableprivate

◆ is_for_listing_

bool attack_type::is_for_listing_ = false
mutableprivate

◆ max_range_

int attack_type::max_range_
private

Definition at line 342 of file attack_type.hpp.

Referenced by max_range(), and write().

◆ min_range_

int attack_type::min_range_
private

Definition at line 342 of file attack_type.hpp.

Referenced by min_range(), and write().

◆ movement_used_

int attack_type::movement_used_
private

Definition at line 349 of file attack_type.hpp.

Referenced by apply_modification(), movement_used(), set_movement_used(), and write().

◆ num_attacks_

int attack_type::num_attacks_
private

Definition at line 344 of file attack_type.hpp.

Referenced by apply_modification(), num_attacks(), set_num_attacks(), and write().

◆ other_

unit_const_ptr attack_type::other_
mutableprivate

◆ other_attack_

const_attack_ptr attack_type::other_attack_
mutableprivate

◆ other_loc_

map_location attack_type::other_loc_
private

◆ parry_

int attack_type::parry_
private

◆ range_

std::string attack_type::range_
private

Definition at line 341 of file attack_type.hpp.

Referenced by apply_modification(), range(), set_range(), and write().

◆ self_

unit_const_ptr attack_type::self_
mutableprivate

◆ self_loc_

map_location attack_type::self_loc_
mutableprivate

◆ specials_

config attack_type::specials_
private

◆ type_

std::string attack_type::type_
private

Definition at line 339 of file attack_type.hpp.

Referenced by apply_modification(), set_type(), type(), and write().


The documentation for this class was generated from the following files: