23 #include "formula/callable_objects.hpp"
31 #define ERR_CF LOG_STREAM(err, log_config)
32 #define WRN_CF LOG_STREAM(warn, log_config)
33 #define LOG_CONFIG LOG_STREAM(info, log_config)
34 #define DBG_CF LOG_STREAM(debug, log_config)
37 #define DBG_UT LOG_STREAM(debug, log_unit)
38 #define ERR_UT LOG_STREAM(err, log_unit)
44 other_attack_(nullptr),
45 description_(cfg[
"description"].t_str()),
50 min_range_(cfg[
"min_range"].to_int(1)),
51 max_range_(cfg[
"max_range"].to_int(1)),
52 damage_(cfg[
"damage"]),
53 num_attacks_(cfg[
"number"]),
54 attack_weight_(cfg[
"attack_weight"].to_double(1.0)),
55 defense_weight_(cfg[
"defense_weight"].to_double(1.0)),
56 accuracy_(cfg[
"accuracy"]),
57 movement_used_(cfg[
"movement_used"].to_int(100000)),
59 specials_(cfg.child_or_empty(
"specials"))
68 icon_ =
"attacks/blank-attack.png";
98 const std::vector<std::string>& filter_range =
utils::split(filter[
"range"]);
99 const std::string& filter_damage = filter[
"damage"];
100 const std::string& filter_attacks = filter[
"number"];
101 const std::string& filter_accuracy = filter[
"accuracy"];
103 const std::string& filter_movement = filter[
"movement_used"];
104 const std::vector<std::string> filter_name =
utils::split(filter[
"name"]);
105 const std::vector<std::string> filter_type =
utils::split(filter[
"type"]);
106 const std::string filter_special = filter[
"special"];
107 const std::string filter_formula = filter[
"formula"];
109 if ( !filter_range.empty() &&
std::find(filter_range.begin(), filter_range.end(), attack.
range()) == filter_range.end() )
127 if ( !filter_name.empty() &&
std::find(filter_name.begin(), filter_name.end(), attack.
id()) == filter_name.end() )
130 if ( !filter_type.empty() &&
std::find(filter_type.begin(), filter_type.end(), attack.
type()) == filter_type.end() )
133 if ( !filter_special.empty() && !attack.
get_special_bool(filter_special,
true) )
136 if (!filter_formula.empty()) {
183 void add_and(std::stringstream &ss) {
201 const t_string& set_desc = cfg[
"set_description"];
204 const std::string& del_specials = cfg[
"remove_specials"];
206 const std::string& increase_damage = cfg[
"increase_damage"];
208 const std::string& increase_attacks = cfg[
"increase_attacks"];
209 const std::string& set_attacks = cfg[
"set_attacks"];
212 const std::string& increase_accuracy = cfg[
"increase_accuracy"];
214 const std::string& increase_parry = cfg[
"increase_parry"];
216 const std::string& increase_movement = cfg[
"increase_movement_used"];
217 const std::string& set_movement = cfg[
"set_movement_used"];
221 if(set_name.empty() ==
false) {
225 if(set_desc.
empty() ==
false) {
229 if(set_type.empty() ==
false) {
233 if(set_icon.empty() ==
false) {
237 if(del_specials.empty() ==
false) {
238 const std::vector<std::string>& dsl =
utils::split(del_specials);
241 std::vector<std::string>::const_iterator found_id =
242 std::find(dsl.begin(), dsl.end(), vp.cfg[
"id"].str());
243 if (found_id == dsl.end()) {
252 if (mode !=
"append") {
260 if(set_damage.empty() ==
false) {
267 if(increase_damage.empty() ==
false) {
274 if(set_attacks.empty() ==
false) {
282 if(increase_attacks.empty() ==
false) {
286 if(set_accuracy.empty() ==
false) {
290 if(increase_accuracy.empty() ==
false) {
294 if(set_parry.empty() ==
false) {
298 if(increase_parry.empty() ==
false) {
302 if(set_movement.empty() ==
false) {
306 if(increase_movement.empty() ==
false) {
310 if(set_attack_weight.empty() ==
false) {
314 if(set_defense_weight.empty() ==
false) {
338 if(description !=
nullptr) {
339 const std::string& increase_damage = cfg[
"increase_damage"];
341 const std::string& increase_attacks = cfg[
"increase_attacks"];
342 const std::string& set_attacks = cfg[
"set_attacks"];
343 const std::string& increase_accuracy = cfg[
"increase_accuracy"];
345 const std::string& increase_parry = cfg[
"increase_parry"];
347 const std::string& increase_movement = cfg[
"increase_movement_used"];
348 const std::string& set_movement = cfg[
"set_movement_used"];
350 std::stringstream desc;
352 if(increase_damage.empty() ==
false) {
356 <<
_n(
"damage",
"damage", inc_damage);
359 if(set_damage.empty() ==
false) {
362 desc << set_damage <<
" " <<
_n(
"damage",
"damage", damage);
365 if(increase_attacks.empty() ==
false) {
369 <<
_n(
"strike",
"strikes", inc_attacks);
372 if(set_attacks.empty() ==
false) {
375 desc << set_attacks <<
" " <<
_n(
"strike",
"strikes", num_attacks);
378 if(set_accuracy.empty() ==
false) {
383 desc << accuracy <<
" " <<
_(
"% accuracy");
386 if(increase_accuracy.empty() ==
false) {
394 if(set_parry.empty() ==
false) {
398 desc << parry <<
_(
" parry");
401 if(increase_parry.empty() ==
false) {
408 if(set_movement.empty() ==
false) {
412 desc << movement_used <<
" " <<
_n(
"movement point",
"movement points",movement_used);
415 if(increase_movement.empty() ==
false) {
418 desc << increase_movement <<
" " <<
_n(
"movement point",
"movement points",inc_move);
421 *description = desc.str();
bool apply_modification(const config &cfg)
Modifies *this using the specifications in cfg, but only if *this matches cfg viewed as a filter...
bool matches_filter(const config &filter) const
Returns whether or not *this matches the given filter.
attack_type(const config &cfg)
int movement_used() const
static lg::log_domain log_unit("unit")
To lexical_cast(From value)
Lexical cast converts one type to another.
bool get_special_bool(const std::string &special, bool simple_check=false) const
Returns whether or not *this has a special with a tag or id equal to special.
static bool matches_simple_filter(const attack_type &attack, const config &filter)
Returns whether or not *this matches the given filter, ignoring the complexities introduced by [and]...
void set_name(const t_string &value)
void write(config &cfg) const
static UNUSEDNOWARN std::string _(const char *str)
GLsizei const GLfloat * value
all_children_itors all_children_range() const
In-order iteration over all children.
static UNUSEDNOWARN std::string _n(const char *str1, const char *str2, int n)
config & add_child(const std::string &key)
const std::string & id() const
std::string egettext(char const *msgid)
const std::string & type() const
void set_defense_weight(double value)
void set_specials(config value)
void set_damage(int value)
std::stringstream & wml_error()
Use this logger to send errors due to deprecated WML.
std::vector< std::pair< int, int > > parse_ranges(std::string const &str)
std::string signed_percent(int val)
Convert into a percentage (using the Unicode "−" and +0% convention.
const std::string & range() const
~attack_type()
Default implementation, but defined out-of-line for efficiency reasons.
std::string accuracy_parry_description() const
bool describe_modification(const config &cfg, std::string *description)
Trimmed down version of apply_modification(), with no modifications actually made.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
void set_parry(int value)
bool find(E event, F functor)
Tests whether an event handler is available.
int apply_modifier(const int number, const std::string &amount, const int minimum)
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
void set_icon(const std::string &value)
Standard logging facilities (interface).
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
std::string signed_value(int val)
Convert into a signed value (using the Unicode "−" and +0 convention.
A config object defines a single node in a WML file, with access to child nodes.
std::string print_modifier(const std::string &mod)
void set_accuracy(int value)
GLsizei const GLcharARB ** string
bool in_ranges(const Cmp c, const std::vector< std::pair< Cmp, Cmp > > &ranges)
void set_attack_weight(double value)
static lg::log_domain log_config("config")
void set_type(const std::string &value)