The Battle for Wesnoth  1.15.1+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 158 of file movetype.hpp.

Constructor & Destructor Documentation

◆ terrain_defense() [1/4]

movetype::terrain_defense::terrain_defense ( )
inline

Definition at line 164 of file movetype.hpp.

◆ terrain_defense() [2/4]

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

Definition at line 165 of file movetype.hpp.

◆ terrain_defense() [3/4]

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

Definition at line 677 of file movetype.cpp.

◆ terrain_defense() [4/4]

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

Definition at line 683 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 177 of file movetype.hpp.

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

◆ 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 704 of file movetype.cpp.

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

Referenced by movetype::merge().

◆ operator=() [1/2]

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

Definition at line 689 of file movetype.cpp.

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

◆ operator=() [2/2]

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

Definition at line 696 of file movetype.cpp.

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

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

References a, b, and swap().

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 491 of file movetype.cpp.

Member Data Documentation

◆ max_

terrain_info movetype::terrain_defense::max_
private

Definition at line 193 of file movetype.hpp.

Referenced by merge(), operator=(), and swap().

◆ min_

terrain_info movetype::terrain_defense::min_
private

Definition at line 192 of file movetype.hpp.

Referenced by merge(), operator=(), and swap().

◆ params_max_

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

Definition at line 161 of file movetype.hpp.

Referenced by movetype::terrain_info::parameters::parameters().

◆ params_min_

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

Definition at line 160 of file movetype.hpp.

Referenced by movetype::terrain_info::parameters::parameters().


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