The Battle for Wesnoth  1.19.17+dev
abilities.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2025
3  by Dominic Bolin <dominic.bolin@exong.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "map/location.hpp"
19 #include "units/ptr.hpp"
20 #include "units/unit.hpp"
21 
23 namespace unit_abilities
24 {
25 bool filter_base_matches(const config& cfg, int def);
26 
28 
30 
31 /**
32  * Substitute gettext variables in name and description of abilities and specials
33  * @param str The string in which the substitution is to be done
34  * @param ab The special (for example [plague][/plague] etc.)
35  *
36  * @return The string `str` with all gettext variables substitutes with corresponding special properties
37  */
38 std::string substitute_variables(const std::string& str, const unit_ability_t& ab);
39 
40 int individual_value(const config::attribute_value *v, int def, const active_ability & ability, const map_location& loc, const const_attack_ptr& att);
41 
42 int individual_double_value(const config::attribute_value *v, int def, const active_ability & ability, const map_location& loc, const const_attack_ptr& att);
43 
45 {
47  loc(map_location::null_location()) {}
48  void set(value_modifier t, int val, const config& abil,const map_location &l);
50  int value;
51  const config *ability;
53 };
54 
55 class effect
56 {
57  public:
58  effect(const active_ability_list& list, int def, const const_attack_ptr& attacker = const_attack_ptr(), EFFECTS wham = EFFECT_DEFAULT);
59  // Provide read-only access to the effect list:
60  typedef std::vector<individual_effect>::const_iterator iterator;
61  typedef std::vector<individual_effect>::const_iterator const_iterator;
62 
63  int get_composite_value() const
64  { return composite_value_; }
66  { return composite_double_value_; }
68  { return effect_list_.begin(); }
70  { return effect_list_.end(); }
71  private:
72  std::vector<individual_effect> effect_list_;
75 };
76 
77 
78 }
map_location loc
Definition: move.cpp:172
double t
Definition: astarsearch.cpp:63
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:157
int get_composite_value() const
Definition: abilities.hpp:63
std::vector< individual_effect > effect_list_
Definition: abilities.hpp:72
effect(const active_ability_list &list, int def, const const_attack_ptr &attacker=const_attack_ptr(), EFFECTS wham=EFFECT_DEFAULT)
Definition: abilities.cpp:2430
const_iterator end() const
Definition: abilities.hpp:69
double get_composite_double_value() const
Definition: abilities.hpp:65
std::vector< individual_effect >::const_iterator const_iterator
Definition: abilities.hpp:61
double composite_double_value_
Definition: abilities.hpp:74
std::vector< individual_effect >::const_iterator iterator
Definition: abilities.hpp:60
const_iterator begin() const
Definition: abilities.hpp:67
const config * cfg
std::string substitute_variables(const std::string &str, const unit_ability_t &ab)
Substitute gettext variables in name and description of abilities and specials.
Definition: abilities.cpp:2396
bool filter_base_matches(const config &cfg, int def)
Definition: abilities.cpp:2375
int individual_value(const config::attribute_value *v, int def, const active_ability &ability, const map_location &loc, const const_attack_ptr &att)
@ EFFECT_WITHOUT_CLAMP_MIN_MAX
Definition: abilities.hpp:29
int individual_double_value(const config::attribute_value *v, int def, const active_ability &ability, const map_location &loc, const const_attack_ptr &att)
std::shared_ptr< const attack_type > const_attack_ptr
Definition: ptr.hpp:34
Data typedef for active_ability_list.
Definition: unit.hpp:37
Encapsulates the map of the game.
Definition: location.hpp:46
void set(value_modifier t, int val, const config &abil, const map_location &l)
Definition: abilities.cpp:2367