70 int result =
value(terrain);
81 virtual void write(
config & cfg,
const std::string & child_name=
"",
bool merged=
true)
const = 0;
137 void merge(
const config & new_values,
bool overwrite,
138 const std::vector<movetype::terrain_info *> & dependants);
142 void write(
config & cfg,
const std::string & child_name=
"",
bool merged=
true)
const override;
202 void merge(
const config & new_data,
bool overwrite);
231 void merge(
const config & new_data,
bool overwrite);
233 void write(
config & out_cfg,
const std::string & child_name=
"")
const;
327 void merge(
const config & new_cfg,
bool overwrite=
true);
337 void merge(
const config & new_cfg,
const std::string & applies_to,
bool overwrite=
true);
A config object defines a single node in a WML file, with access to child nodes.
Stores a set of resistances.
int resistance_against(const std::string &damage_type) const
Returns the vulnerability to the indicated damage type (higher means more damage).
resistances(const config &cfg)
void merge(const config &new_data, bool overwrite)
Merges the given config over the existing costs.
utils::string_map_res damage_table() const
Returns a map from damage types to resistances.
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.
A const-only interface for how many (movement, vision, or "jamming") points a unit needs for each hex...
virtual std::unique_ptr< terrain_costs > make_standalone() const =0
Does a sufficiently deep copy so that the returned object's lifespan is independent of other objects'...
virtual int value(const t_translation::terrain_code &terrain) const =0
Returns the value associated with the given terrain.
virtual void write(config &cfg, const std::string &child_name="", bool merged=true) const =0
Writes our data to a config.
virtual ~terrain_costs()=default
int cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost associated with the given terrain.
Stores a set of defense levels.
terrain_defense & operator=(const terrain_defense &that)
terrain_defense(const config &cfg)
int defense(const t_translation::terrain_code &terrain) const
Returns the defense associated with the given terrain.
void write(config &cfg, const std::string &child_name="") const
Writes our data to a config, as a child if child_name is specified.
bool capped(const t_translation::terrain_code &terrain) const
Returns whether there is a defense cap associated to this terrain.
static const terrain_info::parameters params_max_
friend void swap(movetype::terrain_defense &a, movetype::terrain_defense &b)
Swap function for the terrain_defense class.
static const terrain_info::parameters params_min_
void merge(const config &new_data, bool overwrite)
Merges the given config over the existing costs.
Stores a set of data based on terrain, in some cases with raw pointers to other instances of terrain_...
void make_data_writable() const
Copy the immutable data back to unique_data_, no-op if the data is already in unique_data_.
const data & get_data() const
Returns either *unique_data_ or *shared_data_, choosing the one that currently holds the data.
std::unique_ptr< terrain_costs > make_standalone() const override
Does a sufficiently deep copy so that the returned object's lifespan is independent of other objects'...
std::shared_ptr< const data > shared_data_
void swap_data(movetype::terrain_info &that)
Swap function for the terrain_info class.
void copy_data(const movetype::terrain_info &that)
This is only expected to be called either when 1) both this and that have no siblings,...
bool empty() const
Returns whether or not our data is empty.
terrain_info(const parameters ¶ms, const terrain_info *fallback)
Constructor.
void write(config &cfg, const std::string &child_name="", bool merged=true) const override
Writes our data to a config.
terrain_info & operator=(const terrain_info &that)=delete
int value(const t_translation::terrain_code &terrain) const override
Returns the value associated with the given terrain.
terrain_info(const terrain_info &that)=delete
terrain_info(terrain_info &&that)=delete
~terrain_info() override
Destructor.
terrain_info & operator=(terrain_info &&that)=delete
void make_data_shareable() const
Move data to an immutable copy in shared_data_, no-op if the data is already in shared_data_.
const terrain_info *const fallback_
void merge(const config &new_values, bool overwrite, const std::vector< movetype::terrain_info * > &dependants)
Merges the given config over the existing values.
std::unique_ptr< data > unique_data_
The basic "size" of the unit - flying, small land, large land, etc.
static const int UNREACHABLE
Magic value that signifies a hex is unreachable.
void write(config &cfg, bool include_notes) const
Writes the movement type data to the provided config.
movetype()
Default constructor.
static const std::set< std::string > effects
The set of applicable effects for movement types.
resistances & get_resistances()
void merge(const config &new_cfg, bool overwrite=true)
Merges the given config over the existing data, the config should have zero or more children named "m...
bool has_vision_data() const
Returns whether or not there are any vision-specific costs.
bool has_jamming_data() const
Returns whether or not there are any jamming-specific costs.
bool has_terrain_defense_caps(const std::set< t_translation::terrain_code > &ts) const
Returns whether or not there are any terrain caps with respect to a set of terrains.
int defense_modifier(const t_translation::terrain_code &terrain) const
Returns the defensive value of the indicated terrain.
const terrain_defense & get_defense() const
const terrain_costs & get_jamming() const
movetype & operator=(const movetype &that)
friend void swap(movetype::terrain_info &a, movetype::terrain_info &b)
const resistances & get_resistances() const
static const terrain_info::parameters mvj_params_
Limits for movement, vision and jamming.
static std::unique_ptr< terrain_costs > read_terrain_costs(const config &cfg)
Reverse of terrain_costs::write.
int jamming_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to "jam" through the indicated terrain.
int vision_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to see through the indicated terrain.
int resistance_against(const std::string &damage_type) const
Returns the vulnerability to the indicated damage type (higher means takes more damage).
friend void swap(movetype &a, movetype &b)
Swap function for the movetype class, including its terrain_info members.
std::vector< t_string > special_notes_
int movement_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to move through the indicated terrain.
void set_flying(bool flies=true)
Sets whether or not *this is flagged as a flying movement type.
utils::string_map_res damage_table() const
Returns a map from damage types to resistances.
const terrain_costs & get_movement() const
terrain_defense & get_defense()
const terrain_costs & get_vision() const
const std::vector< t_string > & special_notes() const
Contents of any [special_note] tags.
bool is_flying() const
Returns whether or not *this is flagged as a flying movement type.
Definitions for the interface to Wesnoth Markup Language (WML).
std::map< std::string, t_string, res_compare > string_map_res
The parameters used when calculating a terrain-based value.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...