71 int result = value(terrain);
79 virtual std::unique_ptr<terrain_costs> make_standalone()
const = 0;
82 virtual void write(
config & cfg,
const std::string & child_name=
"",
bool merged=
true)
const = 0;
86 static std::unique_ptr<terrain_costs> read_terrain_costs(
const config & cfg);
139 void merge(
const config & new_values,
bool overwrite,
140 const std::vector<movetype::terrain_info *> & dependants);
144 void write(
config & cfg,
const std::string & child_name=
"",
bool merged=
true)
const override;
145 std::unique_ptr<terrain_costs> make_standalone()
const override;
152 void make_data_shareable()
const;
157 void make_data_writable()
const;
162 const data & get_data()
const;
176 static const int UNREACHABLE = 99;
187 min_(cfg, params_min_, nullptr), max_(cfg, params_max_, nullptr)
196 {
return std::max(min_.value(terrain), max_.value(terrain)); }
199 {
return min_.value(terrain) != 0; }
204 void merge(
const config & new_data,
bool overwrite);
210 { max_.write(cfg, child_name,
false); }
231 int resistance_against(
const attack_type & attack)
const;
233 int resistance_against(
const std::string & damage_type)
const;
235 void merge(
const config & new_data,
bool overwrite);
237 void write(
config & out_cfg,
const std::string & child_name=
"")
const;
283 {
return movement_.cost(terrain,
slowed); }
286 {
return vision_.cost(terrain,
slowed); }
289 {
return jamming_.cost(terrain,
slowed); }
293 {
return defense_.defense(terrain); }
297 {
return resist_.resistance_against(attack); }
300 {
return resist_.resistance_against(damage_type); }
303 {
return resist_.damage_table(); }
306 bool has_terrain_defense_caps(
const std::set<t_translation::terrain_code> & ts)
const;
334 void merge(
const config & new_cfg,
bool overwrite=
true);
344 void merge(
const config & new_cfg,
const std::string & applies_to,
bool overwrite=
true);
350 const std::vector<t_string>&
special_notes()
const {
return special_notes_; }
int defense_modifier(const t_translation::terrain_code &terrain) const
Returns the defensive value of the indicated 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.
int vision_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to see through the indicated terrain.
A const-only interface for how many (movement, vision, or "jamming") points a unit needs for each hex...
bool has_jamming_data() const
Returns whether or not there are any jamming-specific costs.
resistances & get_resistances()
const terrain_info *const fallback_
terrain_defense(const config &cfg)
std::unique_ptr< data > unique_data_
const resistances & get_resistances() const
const terrain_costs & get_jamming() const
int cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost associated with the given terrain.
static const int UNREACHABLE
Magic value that signifies a hex is unreachable.
bool has_vision_data() const
Returns whether or not there are any vision-specific costs.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
int resistance_against(const attack_type &attack) const
Returns the resistance against the indicated attack.
const terrain_defense & get_defense() const
int resistance_against(const std::string &damage_type) const
Returns the resistance against the indicated damage type.
const std::vector< t_string > & special_notes() const
Contents of any [special_note] tags.
The basic "size" of the unit - flying, small land, large land, etc.
bool capped(const t_translation::terrain_code &terrain) const
Returns whether there is a defense cap associated to this terrain.
Definitions for the interface to Wesnoth Markup Language (WML).
resistances(const config &cfg)
int jamming_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to "jam" through the indicated terrain.
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
const terrain_costs & get_movement() const
terrain_defense & get_defense()
const terrain_costs & get_vision() const
static const std::set< std::string > effects
The set of applicable effects for movement types.
Stores a set of resistances.
Stores a set of data based on terrain, in some cases with raw pointers to other instances of terrain_...
std::map< std::string, t_string, res_compare > string_map_res
std::shared_ptr< const data > shared_data_
void swap(config &lhs, config &rhs)
Implement non-member swap function for std::swap (calls config::swap).
static const terrain_info::parameters params_max_
int movement_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to move through the indicated terrain.
bool is_flying() const
Returns whether or not *this is flagged as a flying movement type.
utils::string_map_res damage_table() const
Returns a map from attack types to resistances.
static const terrain_info::parameters mvj_params_
Limits for movement, vision and jamming.
The parameters used when calculating a terrain-based value.
A config object defines a single node in a WML file, with access to child nodes.
int defense(const t_translation::terrain_code &terrain) const
Returns the defense associated with the given terrain.
void set_flying(bool flies=true)
Sets whether or not *this is flagged as a flying movement type.
Stores a set of defense levels.
static const terrain_info::parameters params_min_
std::vector< t_string > special_notes_