The Battle for Wesnoth  1.19.13+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 
21 class unit_ability_list;
22 namespace unit_abilities
23 {
24 bool filter_base_matches(const config& cfg, int def);
25 
27 
29 
30 /**
31  * Substitute gettext variables in name and description of abilities and specials
32  * @param str The string in which the substitution is to be done
33  * @param tag_name Tag name of the special (plague, leadership, chance_to_hit etc.)
34  * @param ability_or_special The config for the special (for example, contents inside [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 std::string& tag_name, const config& ability_or_special);
39 
41 {
43  loc(map_location::null_location()) {}
44  void set(value_modifier t, int val, const config *abil,const map_location &l);
46  int value;
47  const config *ability;
49 };
50 
51 class effect
52 {
53  public:
54  effect(const unit_ability_list& list, int def, const const_attack_ptr& attacker = const_attack_ptr(), EFFECTS wham = EFFECT_DEFAULT);
55  // Provide read-only access to the effect list:
56  typedef std::vector<individual_effect>::const_iterator iterator;
57  typedef std::vector<individual_effect>::const_iterator const_iterator;
58 
59  int get_composite_value() const
60  { return composite_value_; }
62  { return composite_double_value_; }
64  { return effect_list_.begin(); }
66  { return effect_list_.end(); }
67  private:
68  std::vector<individual_effect> effect_list_;
71 };
72 
73 
74 }
double t
Definition: astarsearch.cpp:63
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:158
int get_composite_value() const
Definition: abilities.hpp:59
std::vector< individual_effect > effect_list_
Definition: abilities.hpp:68
const_iterator end() const
Definition: abilities.hpp:65
double get_composite_double_value() const
Definition: abilities.hpp:61
effect(const unit_ability_list &list, int def, const const_attack_ptr &attacker=const_attack_ptr(), EFFECTS wham=EFFECT_DEFAULT)
Definition: abilities.cpp:2433
std::vector< individual_effect >::const_iterator const_iterator
Definition: abilities.hpp:57
double composite_double_value_
Definition: abilities.hpp:70
std::vector< individual_effect >::const_iterator iterator
Definition: abilities.hpp:56
const_iterator begin() const
Definition: abilities.hpp:63
std::string substitute_variables(const std::string &str, const std::string &tag_name, const config &ability_or_special)
Substitute gettext variables in name and description of abilities and specials.
Definition: abilities.cpp:2415
bool filter_base_matches(const config &cfg, int def)
Definition: abilities.cpp:2394
@ EFFECT_WITHOUT_CLAMP_MIN_MAX
Definition: abilities.hpp:28
std::shared_ptr< const attack_type > const_attack_ptr
Definition: ptr.hpp:34
Encapsulates the map of the game.
Definition: location.hpp:45
void set(value_modifier t, int val, const config *abil, const map_location &l)
Definition: abilities.cpp:2386