The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
movetype::terrain_defense Class Reference

Stores a set of defense levels. More...

#include <movetype.hpp>

Public Member Functions

 terrain_defense ()
 
 terrain_defense (const config &cfg)
 
 terrain_defense (const terrain_defense &that)
 
 terrain_defense (terrain_defense &&that)
 
terrain_defenseoperator= (const terrain_defense &that)
 
terrain_defenseoperator= (terrain_defense &&that)
 
int defense (const t_translation::terrain_code &terrain) const
 Returns the defense associated with the given terrain. More...
 
bool capped (const t_translation::terrain_code &terrain) const
 Returns whether there is a defense cap associated to this terrain. More...
 
void merge (const config &new_data, bool overwrite)
 Merges the given config over the existing costs. More...
 
void write (config &cfg, const std::string &child_name="") const
 Writes our data to a config, as a child if child_name is specified. More...
 

Private Attributes

terrain_info min_
 
terrain_info max_
 

Static Private Attributes

static const terrain_info::parameters params_min_
 
static const terrain_info::parameters params_max_
 

Friends

void swap (movetype::terrain_defense &a, movetype::terrain_defense &b)
 Swap function for the terrain_defense class. More...
 

Detailed Description

Stores a set of defense levels.

Definition at line 177 of file movetype.hpp.

Constructor & Destructor Documentation

◆ terrain_defense() [1/4]

movetype::terrain_defense::terrain_defense ( )
inline

Definition at line 183 of file movetype.hpp.

◆ terrain_defense() [2/4]

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

Definition at line 184 of file movetype.hpp.

◆ terrain_defense() [3/4]

movetype::terrain_defense::terrain_defense ( const terrain_defense that)

Definition at line 685 of file movetype.cpp.

◆ terrain_defense() [4/4]

movetype::terrain_defense::terrain_defense ( terrain_defense &&  that)

Definition at line 691 of file movetype.cpp.

Member Function Documentation

◆ capped()

bool movetype::terrain_defense::capped ( const t_translation::terrain_code terrain) const
inline

Returns whether there is a defense cap associated to this terrain.

Definition at line 196 of file movetype.hpp.

References min_, and movetype::terrain_info::value().

Referenced by movetype::has_terrain_defense_caps(), and help::unit_topic_generator::operator()().

◆ defense()

int movetype::terrain_defense::defense ( const t_translation::terrain_code terrain) const
inline

Returns the defense associated with the given terrain.

Definition at line 193 of file movetype.hpp.

References max_, min_, and movetype::terrain_info::value().

Referenced by movetype::defense_modifier().

◆ merge()

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

Merges the given config over the existing costs.

(Not overwriting implies adding.)

Definition at line 714 of file movetype.cpp.

Referenced by movetype::merge().

◆ operator=() [1/2]

movetype::terrain_defense & movetype::terrain_defense::operator= ( const terrain_defense that)

Definition at line 697 of file movetype.cpp.

References max_, and min_.

◆ operator=() [2/2]

movetype::terrain_defense & movetype::terrain_defense::operator= ( terrain_defense &&  that)

Definition at line 704 of file movetype.cpp.

◆ write()

void movetype::terrain_defense::write ( config cfg,
const std::string &  child_name = "" 
) const
inline

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 207 of file movetype.hpp.

References max_, and movetype::terrain_info::write().

Referenced by movetype::write().

Friends And Related Function Documentation

◆ swap

void swap ( movetype::terrain_defense a,
movetype::terrain_defense b 
)
friend

Swap function for the terrain_defense class.

This relies on all of the terrain_infos having no fallback and no cascade, an assumption which is provided by terrain_defense's constructors.

Definition at line 498 of file movetype.cpp.

Member Data Documentation

◆ max_

terrain_info movetype::terrain_defense::max_
private

Definition at line 216 of file movetype.hpp.

Referenced by defense(), operator=(), and write().

◆ min_

terrain_info movetype::terrain_defense::min_
private

Definition at line 215 of file movetype.hpp.

Referenced by capped(), defense(), and operator=().

◆ params_max_

const movetype::terrain_info::parameters movetype::terrain_defense::params_max_
staticprivate

Definition at line 180 of file movetype.hpp.

◆ params_min_

const movetype::terrain_info::parameters movetype::terrain_defense::params_min_
staticprivate

Definition at line 179 of file movetype.hpp.


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