60 static std::string
unit_level_tooltip(
const int level,
const std::vector<std::string> &adv_to_types,
const std::vector<config> &adv_to_mods)
64 const bool has_advancements = !adv_to_types.empty() || !adv_to_mods.empty();
65 if(has_advancements) {
66 tooltip <<
_(
"Advancements:") <<
"\n\t";
67 if(!adv_to_types.empty())
69 if(!adv_to_mods.empty()) {
70 if(!adv_to_types.empty())
72 std::vector<std::string> descriptions;
73 for(
const config& adv : adv_to_mods)
74 descriptions.push_back(adv[
"description"].str());
90 const auto mod_adv_iters =
type.modification_advancements();
91 const std::vector<config> mod_advancements(mod_adv_iters.begin(), mod_adv_iters.end());
103 std::stringstream str;
105 str <<
markup::img(
"themes/gold.png") << unit_recall_cost;
115 if(unit_recall_cost < 0) {
116 unit_recall_cost = team_recall_cost;
119 std::stringstream str;
122 if(unit_recall_cost > team_recall_cost) {
124 }
else if(unit_recall_cost < team_recall_cost) {
129 str << unit_recall_cost;
141 }
else if(
level < 1) {
143 }
else if(
level == 1) {
144 return std::to_string(
level);
145 }
else if(
level == 2) {
147 }
else if(
level == 3) {
171 const std::string& type_id,
177 if(u_type ==
nullptr) {
178 return _(
"Internal error. Please report this as a bug! Details:\n")
179 +
"unit_helper::recruit_message: u_type == nullptr for " + type_id;
184 return VGETTEXT(
"You cannot recruit a $unit_type_name at this time.",
196 if(u_type->
cost() > current_team.
gold() - wb_gold)
200 return _(
"At this point in your plan, you will not have enough gold to recruit this unit.");
202 return _(
"You do not have enough gold to recruit this unit.");
A config object defines a single node in a WML file, with access to child nodes.
std::shared_ptr< wb::manager > get_whiteboard() const
This class stores all the data for a single 'side' (in game nomenclature).
const std::string & last_recruit() const
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
A single unit type that the player may recruit.
const t_string & type_name() const
The name of the unit in the current language setting.
This class represents a single unit of a specific type.
Various functions related to the creation of units (recruits, recalls, and placed units).
static std::string _(const char *str)
int level() const
The current level of this unit.
std::vector< config > get_modification_advances() const
Gets any non-typed advanced options set by modifications.
const advances_to_t & advances_to() const
Gets the possible types this unit can advance to on level-up.
const std::vector< std::string > advances_to_translated() const
Gets the names of the possible types this unit can advance to on level-up.
std::string tooltip
Shown when hovering over an entry in the filter's drop-down list.
std::string find_recruit_location(const int side, map_location &recruit_location, map_location &recruited_from, const std::string &unit_type)
Finds a location on which to place a unit.
const std::set< std::string > get_recruits(int side, const map_location &recruit_loc)
Gets the recruitable units from a side's leaders' personal recruit lists who can recruit on or from a...
const color_t YELLOW_COLOR
const color_t GREEN_COLOR
const color_t INACTIVE_COLOR
color_t red_to_green(double val, bool for_text)
Return a color corresponding to the value val red for val=0.0 to green for val=100....
std::string img(const std::string &src, const std::string &align, bool floating)
Generates a Help markup tag corresponding to an image.
std::string bold(Args &&... data)
Applies bold Pango markup to the input.
std::string span_color(const color_t &color, Args &&... data)
Applies Pango markup to the input specifying its display color.
play_controller * controller
static std::string unit_level_tooltip(const int level, const std::vector< std::string > &adv_to_types, const std::vector< config > &adv_to_mods)
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.
std::string resistance_color(const int resistance)
Maps resistance <= -60 (resistance value <= -60%) to intense red.
std::string format_level_string(const int level, bool recallable)
t_string recruit_message(const std::string &type_id, map_location &target_hex, map_location &recruited_from, team ¤t_team)
std::string format_movement_string(const int moves_left, const int moves_max, bool active)
std::string maybe_inactive(const std::string &str, bool active)
int number_of_possible_advances(const unit &u)
Determines the total number of available advancements (of any kind) for a given unit.
std::string format_cost_string(int unit_recall_cost, bool active)
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::map< std::string, t_string > string_map
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
The basic class for representing 8-bit RGB or RGBA colour values.
std::string to_hex_string() const
Returns the stored color in rrggbb hex format.
Encapsulates the map of the game.
ONLY IF whiteboard is currently active, applies the planned unit map for the duration of the struct's...
Applies the planned unit map for the duration of the struct's life.
unit_type_data unit_types