The Battle for Wesnoth  1.15.0+dev
Public Member Functions | Private Attributes | List of all members
movetype::resistances Class Reference

Stores a set of resistances. More...

#include <movetype.hpp>

Public Member Functions

 resistances ()
 
 resistances (const config &cfg)
 
utils::string_map damage_table () const
 Returns a map from attack types to resistances. More...
 
int resistance_against (const attack_type &attack) const
 Returns the resistance against the indicated attack. More...
 
int resistance_against (const std::string &damage_type) const
 Returns the resistance against the indicated damage type. More...
 
void merge (const config &new_data, bool overwrite)
 Merges the given config over the existing costs. More...
 
void write (config &out_cfg, const std::string &child_name="") const
 Writes our data to a config, as a child if child_name is specified. More...
 

Private Attributes

config cfg_
 

Detailed Description

Stores a set of resistances.

Definition at line 197 of file movetype.hpp.

Constructor & Destructor Documentation

◆ resistances() [1/2]

movetype::resistances::resistances ( )
inline

Definition at line 200 of file movetype.hpp.

◆ resistances() [2/2]

movetype::resistances::resistances ( const config cfg)
inlineexplicit

Definition at line 201 of file movetype.hpp.

References write().

Member Function Documentation

◆ damage_table()

utils::string_map movetype::resistances::damage_table ( ) const

Returns a map from attack types to resistances.

Definition at line 718 of file movetype.cpp.

Referenced by gui2::unit_preview_pane::set_displayed_type().

◆ merge()

void movetype::resistances::merge ( const config new_data,
bool  overwrite 
)

Merges the given config over the existing costs.

If overwrite is false, the new values will be added to the old.

Definition at line 752 of file movetype.cpp.

References a, config::attribute_range(), and config_attribute_value::to_int().

Referenced by movetype::merge().

◆ resistance_against() [1/2]

int movetype::resistances::resistance_against ( const attack_type attack) const

Returns the resistance against the indicated attack.

Definition at line 733 of file movetype.cpp.

References attack_type::type().

◆ resistance_against() [2/2]

int movetype::resistances::resistance_against ( const std::string &  damage_type) const

Returns the resistance against the indicated damage type.

Definition at line 742 of file movetype.cpp.

◆ write()

void movetype::resistances::write ( config out_cfg,
const std::string &  child_name = "" 
) const

Writes our data to a config, as a child if child_name is specified.

(No child is created if there is no data.)

Definition at line 771 of file movetype.cpp.

References config::add_child(), and config::merge_with().

Referenced by movetype::write().

Member Data Documentation

◆ cfg_

config movetype::resistances::cfg_
private

Definition at line 215 of file movetype.hpp.


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