The Battle for Wesnoth  1.19.18+dev
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
unit_ability_t Class Reference

#include <abilities.hpp>

Classes

class  recursion_guard
 
struct  tooltip_info
 

Public Types

enum class  active_on_t { offense , defense , both }
 
enum class  apply_to_t {
  self , opponent , attacker , defender ,
  both
}
 
enum class  affects_allies_t { yes , no , same_side_only }
 
enum class  affects_t { SELF = 1 , OTHER = 2 , EITHER = 3 }
 

Public Member Functions

 unit_ability_t (std::string tag, config cfg, bool inside_attack)
 
const std::string & tag () const
 
const std::string & id () const
 
bool in_specials_tag () const
 
const configcfg () const
 
active_on_t active_on () const
 
apply_to_t apply_to () const
 
double priority () const
 
affects_allies_t affects_allies () const
 
bool affects_self () const
 
bool affects_enemies () const
 
std::string get_help_topic_id () const
 
std::string get_name (bool is_inactive=false, unit_race::GENDER=unit_race::MALE) const
 
std::string get_description (bool is_inactive=false, unit_race::GENDER=unit_race::MALE) const
 
bool active_on_matches (bool student_is_attacker) const
 
void write (config &abilities_cfg)
 
std::string substitute_variables (const std::string &str) const
 Substitute gettext variables in name and description of abilities and specials. More...
 
recursion_guard guard_against_recursion (const unit &u) const
 Tests which might otherwise cause infinite recursion should call this, check that the returned object evaluates to true, and then keep the object returned as long as the recursion might occur, similar to a reentrant mutex that's limited to a small number of reentrances. More...
 
already added
bool matches_filter (const config &filter) const
 

Static Public Member Functions

static ability_ptr create (std::string tag, config cfg, bool inside_attack)
 
static void do_compat_fixes (config &cfg, const std::string &tag, bool inside_attack)
 
static std::string get_help_topic_id (const config &cfg)
 
static void parse_vector (const config &abilities_cfg, ability_vector &res, bool inside_attack)
 
static config vector_to_cfg (const ability_vector &abilities)
 
static ability_vector cfg_to_vector (const config &abilities_cfg, bool inside_attack)
 
static ability_vector filter_tag (const ability_vector &vec, const std::string &tag)
 
static ability_vector clone (const ability_vector &vec)
 

Private Attributes

std::string tag_
 
std::string id_
 
bool in_specials_tag_
 
active_on_t active_on_
 
apply_to_t apply_to_
 
affects_allies_t affects_allies_
 
bool affects_self_
 
bool affects_enemies_
 
double priority_
 
config cfg_
 
bool currently_checked_
 

Detailed Description

Definition at line 31 of file abilities.hpp.

Member Enumeration Documentation

◆ active_on_t

Enumerator
offense 
defense 
both 

Definition at line 35 of file abilities.hpp.

◆ affects_allies_t

Enumerator
yes 
no 
same_side_only 

Definition at line 37 of file abilities.hpp.

◆ affects_t

Enumerator
SELF 
OTHER 
EITHER 

Definition at line 39 of file abilities.hpp.

◆ apply_to_t

Enumerator
self 
opponent 
attacker 
defender 
both 

Definition at line 36 of file abilities.hpp.

Constructor & Destructor Documentation

◆ unit_ability_t()

unit_ability_t::unit_ability_t ( std::string  tag,
config  cfg,
bool  inside_attack 
)

Member Function Documentation

◆ active_on()

active_on_t unit_ability_t::active_on ( ) const
inline

Definition at line 54 of file abilities.hpp.

References active_on_.

Referenced by active_on_matches(), and unit_ability_t().

◆ active_on_matches()

bool unit_ability_t::active_on_matches ( bool  student_is_attacker) const

Definition at line 365 of file abilities.cpp.

References active_on(), both, defense, and offense.

Referenced by attack_type::special_active_impl().

◆ affects_allies()

affects_allies_t unit_ability_t::affects_allies ( ) const
inline

Definition at line 59 of file abilities.hpp.

References affects_allies_.

◆ affects_enemies()

bool unit_ability_t::affects_enemies ( ) const
inline

Definition at line 63 of file abilities.hpp.

References affects_enemies_.

◆ affects_self()

bool unit_ability_t::affects_self ( ) const
inline

Definition at line 61 of file abilities.hpp.

References affects_self_.

Referenced by unit::ability_affects_self().

◆ apply_to()

apply_to_t unit_ability_t::apply_to ( ) const
inline

◆ cfg()

const config& unit_ability_t::cfg ( ) const
inline

◆ cfg_to_vector()

ability_vector unit_ability_t::cfg_to_vector ( const config abilities_cfg,
bool  inside_attack 
)
static

Definition at line 258 of file abilities.cpp.

References parse_vector().

Referenced by attack_type::set_specials_cfg().

◆ clone()

ability_vector unit_ability_t::clone ( const ability_vector vec)
static

Definition at line 276 of file abilities.cpp.

Referenced by unit::advance_to().

◆ create()

static ability_ptr unit_ability_t::create ( std::string  tag,
config  cfg,
bool  inside_attack 
)
inlinestatic

◆ do_compat_fixes()

void unit_ability_t::do_compat_fixes ( config cfg,
const std::string &  tag,
bool  inside_attack 
)
static

◆ filter_tag()

ability_vector unit_ability_t::filter_tag ( const ability_vector vec,
const std::string &  tag 
)
static

Definition at line 265 of file abilities.cpp.

References tag().

Referenced by unit::abilities(), and attack_type::specials().

◆ get_description()

std::string unit_ability_t::get_description ( bool  is_inactive = false,
unit_race::GENDER  gender = unit_race::MALE 
) const

Definition at line 358 of file abilities.cpp.

References cfg_, unit_race::FEMALE, and substitute_variables().

◆ get_help_topic_id() [1/2]

std::string unit_ability_t::get_help_topic_id ( ) const

Definition at line 245 of file abilities.cpp.

References cfg(), and id().

Referenced by help::generate_weapon_special_topics().

◆ get_help_topic_id() [2/2]

std::string unit_ability_t::get_help_topic_id ( const config cfg)
static

Definition at line 236 of file abilities.cpp.

References cfg().

◆ get_name()

std::string unit_ability_t::get_name ( bool  is_inactive = false,
unit_race::GENDER  gender = unit_race::MALE 
) const

Definition at line 351 of file abilities.cpp.

References cfg_, unit_race::FEMALE, and substitute_variables().

◆ guard_against_recursion()

unit_ability_t::recursion_guard unit_ability_t::guard_against_recursion ( const unit u) const

Tests which might otherwise cause infinite recursion should call this, check that the returned object evaluates to true, and then keep the object returned as long as the recursion might occur, similar to a reentrant mutex that's limited to a small number of reentrances.

This only expects to be called in a single thread

Definition at line 400 of file abilities.cpp.

References cfg(), utils::contains(), currently_checked_, config::debug(), ERR_NG, unit::id(), and utils::trim().

Referenced by unit::ability_active(), unit::get_adj_ability_bool(), and unit::get_self_ability_bool().

◆ id()

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

Definition at line 50 of file abilities.hpp.

References id_.

Referenced by get_help_topic_id().

◆ in_specials_tag()

bool unit_ability_t::in_specials_tag ( ) const
inline

Definition at line 51 of file abilities.hpp.

References in_specials_tag_.

Referenced by attack_type::special_active_impl().

◆ matches_filter()

bool unit_ability_t::matches_filter ( const config filter) const

Definition at line 1890 of file abilities.cpp.

References cfg, utils::views::filter, and markup::tag().

Referenced by attack_type::overwrite_special_checking().

◆ parse_vector()

void unit_ability_t::parse_vector ( const config abilities_cfg,
ability_vector res,
bool  inside_attack 
)
static

Definition at line 251 of file abilities.cpp.

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

Referenced by attack_type::attack_type(), cfg_to_vector(), and unit::init().

◆ priority()

double unit_ability_t::priority ( ) const
inline

Definition at line 56 of file abilities.hpp.

References priority_.

◆ substitute_variables()

std::string unit_ability_t::substitute_variables ( const std::string &  str) const

Substitute gettext variables in name and description of abilities and specials.

Parameters
strThe string in which the substitution is to be done
Returns
The string str with all gettext variables substitutes with corresponding special properties

Definition at line 300 of file abilities.cpp.

References cfg(), utils::interpolate_variables_into_string(), tag(), unit_type_data::types(), and unit_types.

Referenced by get_description(), and get_name().

◆ tag()

const std::string& unit_ability_t::tag ( ) const
inline

◆ vector_to_cfg()

config unit_ability_t::vector_to_cfg ( const ability_vector abilities)
static

Definition at line 285 of file abilities.cpp.

Referenced by unit::abilities_cfg(), and attack_type::specials_cfg().

◆ write()

void unit_ability_t::write ( config abilities_cfg)

Definition at line 295 of file abilities.cpp.

References config::add_child(), cfg(), and tag().

Member Data Documentation

◆ active_on_

active_on_t unit_ability_t::active_on_
private

Definition at line 143 of file abilities.hpp.

Referenced by active_on(), and unit_ability_t().

◆ affects_allies_

affects_allies_t unit_ability_t::affects_allies_
private

Definition at line 145 of file abilities.hpp.

Referenced by affects_allies(), and unit_ability_t().

◆ affects_enemies_

bool unit_ability_t::affects_enemies_
private

Definition at line 147 of file abilities.hpp.

Referenced by affects_enemies(), and unit_ability_t().

◆ affects_self_

bool unit_ability_t::affects_self_
private

Definition at line 146 of file abilities.hpp.

Referenced by affects_self(), and unit_ability_t().

◆ apply_to_

apply_to_t unit_ability_t::apply_to_
private

Definition at line 144 of file abilities.hpp.

Referenced by apply_to(), and unit_ability_t().

◆ cfg_

config unit_ability_t::cfg_
private

Definition at line 149 of file abilities.hpp.

Referenced by cfg(), get_description(), get_name(), and unit_ability_t().

◆ currently_checked_

bool unit_ability_t::currently_checked_
mutableprivate

Definition at line 151 of file abilities.hpp.

Referenced by guard_against_recursion().

◆ id_

std::string unit_ability_t::id_
private

Definition at line 140 of file abilities.hpp.

Referenced by id().

◆ in_specials_tag_

bool unit_ability_t::in_specials_tag_
private

Definition at line 142 of file abilities.hpp.

Referenced by in_specials_tag().

◆ priority_

double unit_ability_t::priority_
private

Definition at line 148 of file abilities.hpp.

Referenced by priority().

◆ tag_

std::string unit_ability_t::tag_
private

Definition at line 139 of file abilities.hpp.

Referenced by tag(), and unit_ability_t().


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