The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
movetype Class Reference

The basic "size" of the unit - flying, small land, large land, etc. More...

#include <movetype.hpp>

Classes

class  resistances
 Stores a set of resistances. More...
 
class  terrain_costs
 Stores a set of terrain costs (for movement, vision, or "jamming"). More...
 
class  terrain_defense
 Stores a set of defense levels. More...
 
class  terrain_info
 Stores a set of data based on terrain. More...
 

Public Member Functions

 movetype ()
 Default constructor. More...
 
 movetype (const config &cfg)
 Constructor from a config. More...
 
 movetype (const movetype &that)
 Copy constructor. More...
 
terrain_costsget_movement ()
 
terrain_costsget_vision ()
 
terrain_costsget_jamming ()
 
terrain_defenseget_defense ()
 
resistancesget_resistances ()
 
const terrain_costsget_movement () const
 
const terrain_costsget_vision () const
 
const terrain_costsget_jamming () const
 
const terrain_defenseget_defense () const
 
const resistancesget_resistances () const
 
bool is_flying () const
 Returns whether or not *this is flagged as a flying movement type. More...
 
void set_flying (bool flies=true)
 Sets whether or not *this is flagged as a flying movement type. More...
 
int movement_cost (const t_translation::t_terrain &terrain, bool slowed=false) const
 Returns the cost to move through the indicated terrain. More...
 
int vision_cost (const t_translation::t_terrain &terrain, bool slowed=false) const
 Returns the cost to see through the indicated terrain. More...
 
int jamming_cost (const t_translation::t_terrain &terrain, bool slowed=false) const
 Returns the cost to "jam" through the indicated terrain. More...
 
int defense_modifier (const t_translation::t_terrain &terrain) const
 Returns the defensive value of the indicated terrain. 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...
 
utils::string_map damage_table () const
 Returns a map from attack types to resistances. More...
 
bool has_terrain_defense_caps (const std::set< t_translation::t_terrain > &ts) const
 Returns whether or not there are any terrain caps with respect to a set of terrains. More...
 
bool has_vision_data () const
 Returns whether or not there are any vision-specific costs. More...
 
bool has_jamming_data () const
 Returns whether or not there are any jamming-specific costs. More...
 
void merge (const config &new_cfg, bool overwrite=true)
 Merges the given config over the existing data. More...
 
void write (config &cfg) const
 Writes the movement type data to the provided config. More...
 

Static Public Attributes

static const int UNREACHABLE = 99
 Magic value that signifies a hex is unreachable. More...
 
static const std::set
< std::string
effects
 The set of applicable effects for movement types. More...
 

Private Attributes

terrain_costs movement_
 
terrain_costs vision_
 
terrain_costs jamming_
 
terrain_defense defense_
 
resistances resist_
 
bool flying_
 

Detailed Description

The basic "size" of the unit - flying, small land, large land, etc.

This encompasses terrain costs, defenses, and resistances.

Definition at line 28 of file movetype.hpp.

Constructor & Destructor Documentation

movetype::movetype ( )

Default constructor.

Definition at line 701 of file movetype.cpp.

movetype::movetype ( const config cfg)
explicit

Constructor from a config.

Definition at line 715 of file movetype.cpp.

movetype::movetype ( const movetype that)

Copy constructor.

Definition at line 729 of file movetype.cpp.

Member Function Documentation

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

Returns a map from attack types to resistances.

Definition at line 219 of file movetype.hpp.

References movetype::resistances::damage_table(), and resist_.

Referenced by unit::get_base_resistances(), and help::unit_topic_generator::operator()().

int movetype::defense_modifier ( const t_translation::t_terrain terrain) const
inline

Returns the defensive value of the indicated terrain.

Definition at line 209 of file movetype.hpp.

References movetype::terrain_defense::defense(), and defense_.

Referenced by unit::defense_modifier(), ai::default_recruitment::recruitment::get_average_defense(), and help::unit_topic_generator::operator()().

terrain_defense& movetype::get_defense ( )
inline

Definition at line 184 of file movetype.hpp.

References defense_.

Referenced by unit::apply_builtin_effect(), and help::unit_topic_generator::operator()().

const terrain_defense& movetype::get_defense ( ) const
inline

Definition at line 190 of file movetype.hpp.

References defense_.

terrain_costs& movetype::get_jamming ( )
inline

Definition at line 183 of file movetype.hpp.

References jamming_.

Referenced by unit::apply_builtin_effect(), and pathfind::jamming_path::jamming_path().

const terrain_costs& movetype::get_jamming ( ) const
inline

Definition at line 189 of file movetype.hpp.

References jamming_.

terrain_costs& movetype::get_movement ( )
inline
const terrain_costs& movetype::get_movement ( ) const
inline

Definition at line 187 of file movetype.hpp.

References movement_.

resistances& movetype::get_resistances ( )
inline

Definition at line 185 of file movetype.hpp.

References resist_.

Referenced by unit::apply_builtin_effect().

const resistances& movetype::get_resistances ( ) const
inline

Definition at line 191 of file movetype.hpp.

References resist_.

terrain_costs& movetype::get_vision ( )
inline
const terrain_costs& movetype::get_vision ( ) const
inline

Definition at line 188 of file movetype.hpp.

References vision_.

bool movetype::has_jamming_data ( ) const
inline

Returns whether or not there are any jamming-specific costs.

Definition at line 227 of file movetype.hpp.

References movetype::terrain_info::empty(), and jamming_.

Referenced by help::unit_topic_generator::operator()().

bool movetype::has_terrain_defense_caps ( const std::set< t_translation::t_terrain > &  ts) const

Returns whether or not there are any terrain caps with respect to a set of terrains.

Checks if we have a defense cap (nontrivial min value) for any of the given terrain types.

Definition at line 742 of file movetype.cpp.

References movetype::terrain_defense::capped(), and defense_.

Referenced by help::unit_topic_generator::operator()().

bool movetype::has_vision_data ( ) const
inline

Returns whether or not there are any vision-specific costs.

Definition at line 225 of file movetype.hpp.

References movetype::terrain_info::empty(), and vision_.

Referenced by help::unit_topic_generator::operator()().

bool movetype::is_flying ( ) const
inline

Returns whether or not *this is flagged as a flying movement type.

Definition at line 194 of file movetype.hpp.

References flying_.

Referenced by unit::is_flying().

int movetype::jamming_cost ( const t_translation::t_terrain terrain,
bool  slowed = false 
) const
inline

Returns the cost to "jam" through the indicated terrain.

Definition at line 205 of file movetype.hpp.

References movetype::terrain_costs::cost(), jamming_, and game_config::sounds::status::slowed.

Referenced by unit::jamming_cost(), and help::unit_topic_generator::operator()().

void movetype::merge ( const config new_cfg,
bool  overwrite = true 
)

Merges the given config over the existing data.

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

Definition at line 754 of file movetype.cpp.

References config::child_range(), defense_, flying_, jamming_, movetype::terrain_info::merge(), movetype::terrain_defense::merge(), movetype::resistances::merge(), movement_, resist_, and vision_.

Referenced by unit_type::build_help_index(), help::unit_topic_generator::operator()(), and unit::unit().

int movetype::movement_cost ( const t_translation::t_terrain terrain,
bool  slowed = false 
) const
inline

Returns the cost to move through the indicated terrain.

Definition at line 199 of file movetype.hpp.

References movetype::terrain_costs::cost(), movement_, and game_config::sounds::status::slowed.

Referenced by pathfind::move_type_path_calculator::cost(), unit::movement_cost(), and help::unit_topic_generator::operator()().

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

Returns the resistance against the indicated attack.

Definition at line 213 of file movetype.hpp.

References resist_, and movetype::resistances::resistance_against().

Referenced by unit_type::resistance_against(), and unit::resistance_against().

int movetype::resistance_against ( const std::string damage_type) const
inline

Returns the resistance against the indicated damage type.

Definition at line 216 of file movetype.hpp.

References resist_, and movetype::resistances::resistance_against().

void movetype::set_flying ( bool  flies = true)
inline

Sets whether or not *this is flagged as a flying movement type.

Definition at line 196 of file movetype.hpp.

References flying_.

int movetype::vision_cost ( const t_translation::t_terrain terrain,
bool  slowed = false 
) const
inline

Returns the cost to see through the indicated terrain.

Definition at line 202 of file movetype.hpp.

References movetype::terrain_costs::cost(), game_config::sounds::status::slowed, and vision_.

Referenced by help::unit_topic_generator::operator()(), and unit::vision_cost().

void movetype::write ( config cfg) const

Writes the movement type data to the provided config.

Definition at line 792 of file movetype.cpp.

References defense_, flying_, jamming_, movement_, resist_, vision_, movetype::terrain_info::write(), movetype::terrain_defense::write(), and movetype::resistances::write().

Referenced by movetype::terrain_info::get_merged(), and unit::write().

Member Data Documentation

terrain_defense movetype::defense_
private

Definition at line 242 of file movetype.hpp.

Referenced by defense_modifier(), get_defense(), has_terrain_defense_caps(), merge(), and write().

const std::set< std::string > movetype::effects
static
Initial value:
= {"movement_costs",
"vision_costs", "jamming_costs", "defense", "resistance"}

The set of applicable effects for movement types.

The set of strings defining effects which apply to movetypes.

Definition at line 233 of file movetype.hpp.

Referenced by help::unit_topic_generator::operator()().

bool movetype::flying_
private

Definition at line 245 of file movetype.hpp.

Referenced by is_flying(), merge(), set_flying(), and write().

terrain_costs movetype::jamming_
private

Definition at line 241 of file movetype.hpp.

Referenced by get_jamming(), has_jamming_data(), jamming_cost(), merge(), and write().

terrain_costs movetype::movement_
private

Definition at line 239 of file movetype.hpp.

Referenced by get_movement(), merge(), movement_cost(), and write().

resistances movetype::resist_
private

Definition at line 243 of file movetype.hpp.

Referenced by damage_table(), get_resistances(), merge(), resistance_against(), and write().

const int movetype::UNREACHABLE = 99
static

Magic value that signifies a hex is unreachable.

The UNREACHABLE macro in the data tree should match this value.

Definition at line 85 of file movetype.hpp.

Referenced by movetype::terrain_costs::cost(), pathfind::find_vacant_tile(), and REPORT_GENERATOR().

terrain_costs movetype::vision_
private

Definition at line 240 of file movetype.hpp.

Referenced by get_vision(), has_vision_data(), merge(), vision_cost(), and write().


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