The Battle for Wesnoth  1.19.7+dev
helper.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.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 "units/map.hpp"
19 
20 namespace unit_helper {
21 
22 /**
23  * Encapsulates the logic for deciding whether an iterator @a u points to
24  * a unit that can advance.
25  * @return true if the unit exists, has available advances, and can_advance().
26  */
28 
29 /**
30  * Determines the total number of available advancements (of any kind) for
31  * a given unit. This includes normal advances and modifiers.
32  * @return the total number of possible advancements.
33  */
35 
36 /**
37  * @return the name of the color encoding the weight of the unit's
38  * resistance value for presenting it to the player.
39  */
40 std::string resistance_color(const int resistance);
41 
42 /**
43  * @return the tooltip text showing a unit's level and what it can advance to.
44  */
45 std::string unit_level_tooltip(const unit &u);
46 
47 /**
48  * @return the tooltip text showing a unit type's level and what it can
49  * advance to.
50  */
51 std::string unit_level_tooltip(const unit_type &u);
52 }
A single unit type that the player may recruit.
Definition: types.hpp:43
This class represents a single unit of a specific type.
Definition: unit.hpp:133
static std::string unit_level_tooltip(const int level, const std::vector< std::string > &adv_to_types, const std::vector< config > &adv_to_mods)
Definition: helper.cpp:55
bool will_certainly_advance(const unit_map::iterator &u)
Encapsulates the logic for deciding whether an iterator u points to a unit that can advance.
Definition: helper.cpp:34
std::string resistance_color(const int resistance)
Maps resistance <= -60 (resistance value <= -60%) to intense red.
Definition: helper.cpp:49
int number_of_possible_advances(const unit &u)
Determines the total number of available advancements (of any kind) for a given unit.
Definition: helper.cpp:29