45 #include <boost/format.hpp>
49 #ifdef __cpp_lib_format
54 const std::string &
tooltip,
const std::string &
help =
"")
57 element[
"text"] = text;
59 if (!
help.empty()) element[
"help"] =
help;
63 const std::string &
tooltip,
const std::string &
help =
"")
66 element[
"image"] =
image;
68 if (!
help.empty()) element[
"help"] =
help;
72 const std::string &
tooltip =
"",
const std::string &
help =
"")
80 const std::string &
tooltip =
"",
const std::string &
help =
"")
90 const std::string&
path,
char const *desc1,
char const *desc2)
97 static std::string
flush(std::ostringstream &
s)
99 std::string r(
s.str());
100 s.str(std::string());
110 }
else if (viewing_team.
fogged(hex)) {
129 #define REPORT_GENERATOR(n, cn) \
130 static config report_##n(const reports::context& cn); \
131 static report_generator_helper reg_gen_##n(#n, &report_##n); \
132 static config report_##n(const reports::context& cn)
174 std::ostringstream str,
tooltip;
199 tooltip <<
"\n\n" <<
_(
"Special Notes:") <<
'\n';
200 for(
const auto& note : notes) {
221 std::ostringstream str,
tooltip;
242 return VGETTEXT(
"Side: <b>$side_name</b> ($color_name)",
255 std::string new_rgb = u_team.
color();
256 std::string mods =
"~RC(" + old_rgb +
">" + new_rgb +
")";
260 std::stringstream text;
261 text <<
" " << u->
side();
300 typedef std::pair<std::string, std::string> pair_string;
301 for (
const pair_string &ps : u->
amla_icons()) {
311 const std::vector<t_string> &traits = u->
trait_names();
314 unsigned nb = traits.size();
315 for (
unsigned i = 0;
i < nb; ++
i)
317 std::ostringstream str,
tooltip;
319 if (
i != nb - 1 ) str <<
", ";
344 N_(
"This unit is invisible. It cannot be seen or attacked by enemy units."));
348 N_(
"This unit has been slowed. It will only deal half its normal damage when attacking and its movement cost is doubled."));
352 N_(
"This unit is poisoned. It will lose 8 HP every turn until it can seek a cure to the poison in a village or from a friendly unit with the ‘cures’ ability.\n\nUnits cannot be killed by poison alone. The poison will not reduce it below 1 HP."));
356 N_(
"This unit has been petrified. It may not move or attack."));
359 add_status(res,
"misc/unhealable.png",
N_(
"unhealable:"),
360 N_(
"This unit is unhealable. It cannot be healed by healers or villages and doesn’t benefit from resting."));
363 add_status(res,
"misc/invulnerable.png",
N_(
"invulnerable:"),
364 N_(
"This unit is invulnerable. It cannot be harmed by any attack."));
382 std::ostringstream str,
tooltip;
402 const map_location& mouseover_hex = rc.screen().mouseover_hex();
403 const map_location& displayed_unit_hex = rc.screen().displayed_unit_hex();
404 const map_location& hex = mouseover_hex.
valid() ? mouseover_hex : displayed_unit_hex;
421 boost::dynamic_bitset<> active;
424 const std::size_t abilities_size = abilities.size();
425 for(std::size_t
i = 0;
i != abilities_size; ++
i) {
427 const auto& [display_name, description, help_id] = abilities[
i];
429 std::ostringstream str,
tooltip;
437 if(
i + 1 != abilities_size) {
446 tooltip <<
'\n' << description;
456 const team &viewing_team = rc.screen().viewing_team();
457 const map_location& mouseover_hex = rc.screen().mouseover_hex();
458 const map_location& displayed_unit_hex = rc.screen().displayed_unit_hex();
459 const map_location& hex = (mouseover_hex.
valid() && !viewing_team.
shrouded(mouseover_hex)) ? mouseover_hex : displayed_unit_hex;
467 const map_location& mouseover_hex = rc.screen().mouseover_hex();
469 const team &viewing_team = rc.screen().viewing_team();
471 if (visible_unit && u && visible_unit->
id() != u->
id() && mouseover_hex.
valid() && !viewing_team.
shrouded(mouseover_hex))
481 std::ostringstream str,
tooltip;
484 std::vector<std::string> resistances_table;
486 bool att_def_diff =
false;
490 std::ostringstream
line;
496 if (res_att == res_def) {
504 resistances_table.push_back(
line.str());
507 tooltip <<
_(
"Resistances:") <<
" ";
511 for (
const std::string &
line : resistances_table) {
530 std::ostringstream str,
tooltip;
538 tooltip <<
_(
"Experience Modifier:") <<
" " << exp_mod <<
'%';
578 std::ostringstream str,
tooltip;
591 if (underlyings.size() != 1 || underlyings.front() != terrain.
number())
605 << (revert ?
_(
"maximum^max.") :
_(
"minimum^min.")) <<
'\n';
617 const team &viewing_team = rc.screen().viewing_team();
618 const map_location& mouseover_hex = rc.screen().mouseover_hex();
619 const map_location& displayed_unit_hex = rc.screen().displayed_unit_hex();
620 const map_location& hex = (mouseover_hex.
valid() && !viewing_team.
shrouded(mouseover_hex)) ? mouseover_hex : displayed_unit_hex;
627 if(attack_indicator_src.
valid())
630 const map_location& mouseover_hex = rc.screen().mouseover_hex();
632 if(visible_unit && u && visible_unit->
id() != u->
id() && mouseover_hex.
valid())
642 std::ostringstream str,
tooltip;
645 str <<
_(
"vision^V:") <<
' ' << u->
vision();
665 std::ostringstream str,
tooltip;
668 str <<
_(
"jamming^J:") <<
' ' << u->
jamming();
682 std::ostringstream str,
tooltip;
683 double movement_frac = 1.0;
685 std::set<terrain_movement> terrain_moves;
689 if (movement_frac > 1.0)
693 tooltip <<
_(
"Movement Costs:") <<
"\n";
700 if (
info.union_type().size() == 1 &&
info.union_type()[0] ==
info.number() &&
info.is_nonnull()) {
710 double movement_red_to_green = 100.0 - 25.0 * tm.moves;
712 std::stringstream temp_str;
717 }
else if (cannot_move) {
718 temp_str <<
"(" << tm.moves <<
")";
720 temp_str << tm.moves;
723 const int movement_hexes_per_turn = u->
total_movement() / tm.moves;
725 for (
int i = 0;
i < movement_hexes_per_turn; ++
i) {
727 temp_str <<
"\u2b23\u200b";
737 int grey = 128 +
static_cast<int>((255 - 128) * movement_frac);
740 if(is_visible_unit) {
742 if(route.
steps.size() > 0) {
751 const auto& end = route.
marks.find(route.
steps.back());
752 if(end != route.
marks.end() && end->second.capture) {
789 std::ostringstream str,
tooltip;
793 struct string_with_tooltip {
800 int base_damage =
at.damage();
801 double specials_damage =
at.modified_damage();
802 int damage_multiplier = 100;
806 damage_multiplier += tod_bonus;
808 if (leader_bonus != 0)
809 damage_multiplier += leader_bonus;
812 int damage_divisor =
slowed ? 20000 : 10000;
814 damage =
round_damage(specials_damage, damage_multiplier * 100, damage_divisor);
818 unsigned cur_hp = std::min<unsigned>(std::max(0, u.
hitpoints()), max_hp);
820 unsigned base_attacks =
at.num_attacks();
821 unsigned min_attacks, max_attacks;
822 at.modified_attacks(min_attacks, max_attacks);
823 unsigned num_attacks =
swarm_blows(min_attacks, max_attacks, cur_hp, max_hp);
826 if (damage > std::round(specials_damage)) {
828 }
else if (damage < std::round(specials_damage)) {
838 if ( tod_bonus || leader_bonus ||
slowed || specials_damage != base_damage )
840 tooltip <<
'\t' <<
_(
"Base damage:") <<
" " << base_damage <<
'\n';
841 if ( specials_damage != base_damage ) {
842 tooltip <<
'\t' <<
_(
"With specials:") <<
" " << specials_damage <<
'\n';
845 tooltip <<
'\t' <<
_(
"Time of day:") <<
" "
849 tooltip <<
'\t' <<
_(
"Leadership:") <<
" "
853 tooltip <<
'\t' <<
_(
"Slowed:") <<
" " <<
"/ 2" <<
'\n';
858 if ( max_attacks != min_attacks && cur_hp != max_hp ) {
859 if ( max_attacks < min_attacks ) {
861 tooltip <<
'\t' <<
_(
"Max swarm bonus:") <<
" " << (min_attacks-max_attacks) <<
'\n';
862 tooltip <<
'\t' <<
_(
"Swarm:") <<
" " <<
"* "<< (100 - cur_hp*100/max_hp) <<
"%\n";
863 tooltip <<
'\t' <<
_(
"Base attacks:") <<
" " <<
'+' << base_attacks <<
'\n';
867 if ( max_attacks != base_attacks ) {
868 int attack_diff =
static_cast<int>(max_attacks) -
static_cast<int>(base_attacks);
874 tooltip <<
'\t' <<
_(
"Base attacks:") <<
" " << base_attacks <<
'\n';
875 if ( max_attacks != base_attacks ) {
876 tooltip <<
'\t' <<
_(
"With specials:") <<
" " << max_attacks <<
'\n';
878 if ( min_attacks != 0 ) {
879 tooltip <<
'\t' <<
_(
"Subject to swarm:") <<
" " << (max_attacks-min_attacks) <<
'\n';
881 tooltip <<
'\t' <<
_(
"Swarm:") <<
" " <<
"* "<< (cur_hp*100/max_hp) <<
"%\n";
884 else if ( num_attacks != base_attacks ) {
885 tooltip <<
'\t' <<
_(
"Base attacks:") <<
" " << base_attacks <<
'\n';
886 tooltip <<
'\t' <<
_(
"With specials:") <<
" " << num_attacks <<
'\n';
892 std::pair<std::string, std::set<std::string>> all_damage_types =
at.damage_types();
893 std::string
type = all_damage_types.first;
894 std::set<std::string> alt_types = all_damage_types.second;
896 for(
auto alt_t : alt_types){
901 const std::string range_png = std::string(
"icons/profiles/") +
at.range() +
"_attack.png~SCALE_INTO(16,16)";
902 const std::string type_png = std::string(
"icons/profiles/") +
type +
".png~SCALE_INTO(16,16)";
903 std::vector<std::string> secondary_types_png;
904 for(
const auto& alt_t : alt_types) {
905 secondary_types_png.push_back(std::string(
"icons/profiles/") + alt_t +
".png~SCALE_INTO(16,16)");
911 for(
const auto& png : secondary_types_png) {
914 if(!all_pngs_exist) {
920 <<
_(
"Damage type:") <<
" " <<
markup::bold(lang_type) <<
"\n"
921 <<
_(
"Damage versus:") <<
" " <<
'\n';
925 std::map<int, std::set<std::string>, std::greater<int>> resistances;
926 std::set<std::string> seen_types;
931 if (
enemy.incapacitated())
937 if (!
enemy.is_visible_to_team(viewing_team, see_all))
939 bool new_type = seen_types.insert(
enemy.type_id()).second;
942 { u.shared_from_this(), hex,
at.shared_from_this() },
943 {
enemy.shared_from_this(),
loc,
nullptr },
945 const auto [damage_type, resistance] = weapon->effective_damage_type();
946 resistances[resistance].insert(
enemy.type_name());
950 for (
const auto& resist : resistances) {
951 int damage_with_resistance =
round_damage(specials_damage, damage_multiplier * resist.first, damage_divisor);
964 const std::string attack_icon =
at.icon() +
"~SCALE_INTO_SHARP(60,60)~CROP(2,2,56,56)~SCALE_INTO_SHARP(32,32)";
970 const std::string spacer =
"misc/blank.png~CROP(0, 0, 16, 21)";
971 add_image(res, spacer +
"~BLIT(" + range_png +
",0,5)", damage_versus.tooltip);
972 add_image(res, spacer +
"~BLIT(" + type_png +
",0,5)", damage_versus.tooltip);
973 for(
auto sec_exist : secondary_types_png){
975 add_image(res, spacer +
"~BLIT(" + sec_exist +
",0,5)", damage_versus.tooltip);
978 add_text(res, damage_and_num_attacks.str, damage_and_num_attacks.tooltip);
979 add_text(res, damage_versus.str, damage_versus.tooltip);
998 if(
at.attacks_used() > 1)
1000 const std::string& attacks_used =
VNGETTEXT(
1002 "uses $num attacks",
1004 { {
"num", std::to_string(at.attacks_used())} }
1008 const std::string& attacks_used_tooltip =
VNGETTEXT(
1009 "This attack uses $num attack point",
1010 "This attack uses $num attack points",
1012 { {
"num", std::to_string(at.attacks_used())} }
1017 const std::string &accuracy_parry =
at.accuracy_parry_description();
1018 if (!accuracy_parry.empty())
1028 { u.shared_from_this(), hex,
at.shared_from_this() },
1029 { sec_u ? sec_u->shared_from_this() :
nullptr, sec_u ? sec_u->get_location() :
map_location(), sec_u_weapon },
1034 boost::dynamic_bitset<> active;
1035 auto specials = ctx.special_tooltips(
at, active);
1036 const std::size_t specials_size = specials.size();
1037 for ( std::size_t
i = 0;
i != specials_size; ++
i )
1040 const auto& name = specials[
i].name;
1041 const auto& description = specials[
i].description;
1042 const color_t &details_color =
1045 str <<
span_color(details_color,
" ",
" ", name) <<
'\n';
1046 std::string help_page =
"weaponspecial_" + specials[
i].help_topic_id;
1051 tooltip <<
'\n' << description;
1056 if(!specials.empty()) {
1061 const std::string spacer =
"misc/blank.png~CROP(0, 0, 1, 5)";
1071 { u.shared_from_this(), hex,
at.shared_from_this() },
1072 { sec_u ? sec_u->shared_from_this() :
nullptr, sec_u ? sec_u->get_location() :
map_location(), sec_u_weapon },
1075 boost::dynamic_bitset<> active;
1077 const std::size_t specials_size = specials.size();
1078 for ( std::size_t
i = 0;
i != specials_size; ++
i )
1081 const auto& [name, description, help_topic_id] = specials[
i];
1082 const color_t& details_color =
1085 str <<
span_color(details_color,
" ",
" ", name) <<
'\n';
1086 const std::string help_page =
"weaponspecial_" + help_topic_id;
1091 tooltip <<
'\n' << description;
1096 if(!specials.empty()) {
1101 const std::string spacer =
"misc/blank.png~CROP(0, 0, 1, 5)";
1114 }
else if(prob < 0.0005) {
1117 std::ostringstream res;
1118 res << std::setprecision(prob < 0.01 ? 1 : prob < 0.1 ? 2 : 3) << 100.0 * prob <<
"%";
1124 std::ostringstream res;
1125 res <<
' ' << std::setw(3) << hp;
1131 if (!attacker || !defender)
return config();
1133 const unit* u = show_attacker ? attacker.get() : defender;
1134 const unit* sec_u = !show_attacker ? attacker.get() : defender;
1137 std::ostringstream str,
tooltip;
1140 std::vector<battle_context> weapons;
1141 for (
unsigned i = 0;
i < attacker->attacks().
size();
i++) {
1143 if (attacker->attacks()[
i].attack_weight() > 0) {
1144 weapons.emplace_back(rc.
units(), attacker_pos, defender->
get_location(),
i, -1, 0.0,
nullptr, attacker);
1151 combatant attacker_combatant(weapon.get_attacker_stats());
1152 combatant defender_combatant(weapon.get_defender_stats());
1153 attacker_combatant.
fight(defender_combatant);
1156 show_attacker ? weapon.get_attacker_stats() : weapon.get_defender_stats();
1158 !show_attacker ? weapon.get_attacker_stats() : weapon.get_defender_stats();
1160 int total_damage = 0;
1161 int base_damage = 0;
1163 int chance_to_hit = 0;
1164 t_string weapon_name =
_(
"weapon^None");
1167 if (context_unit_stats.
weapon) {
1168 base_damage =
attack_info(rc, *context_unit_stats.
weapon, res, *u, unit_loc, sec_u, other_context_unit_stats.
weapon);
1169 total_damage = context_unit_stats.
damage;
1170 num_blows = context_unit_stats.
num_blows;
1172 weapon_name = context_unit_stats.
weapon->name();
1174 if ( total_damage > base_damage ) {
1176 }
else if ( total_damage < base_damage ) {
1188 str <<
" " <<
span_color(dmg_color, total_damage)
1197 std::vector<std::pair<int, double>> hp_prob_vector;
1200 std::vector<std::pair<double, int>> prob_hp_vector;
1202 combatant*
c = show_attacker ? &attacker_combatant : &defender_combatant;
1205 for (
double prob :
c->hp_dist) {
1208 prob_hp_vector.emplace_back(prob,
i);
1213 std::sort(prob_hp_vector.begin(), prob_hp_vector.end());
1216 std::size_t max_hp_distrib_rows_ = 10;
1219 std::size_t nb_elem = std::min<std::size_t>(max_hp_distrib_rows_, prob_hp_vector.size());
1221 for(std::size_t
i = prob_hp_vector.size() - nb_elem;
i <prob_hp_vector.size();
i++) {
1222 hp_prob_vector.emplace_back(prob_hp_vector[
i].second, prob_hp_vector[
i].first);
1226 std::sort(hp_prob_vector.begin(), hp_prob_vector.end());
1228 std::reverse(hp_prob_vector.begin(), hp_prob_vector.end());
1230 for (
const auto& [hp, prob] : hp_prob_vector) {
1251 if ((u !=
nullptr) && (!u->
attacks().empty())) {
1252 const std::string attack_headline =
_n(
"Attack",
"Attacks", u->
attacks().size());
1259 const std::string
line =
VGETTEXT(
"Remaining: $left/$max",
1260 {{
"left", std::to_string(left)},
1261 {
"max", std::to_string(max)}});
1263 _(
"This unit can attack multiple times per turn."));
1276 const map_location& mouseover_hex = rc.screen().mouseover_hex();
1277 const map_location& displayed_unit_hex = rc.screen().displayed_unit_hex();
1278 const map_location& hex = mouseover_hex.
valid() ? mouseover_hex : displayed_unit_hex;
1288 if (!u)
return report_unit_weapons(rc);
1289 if (!sec_u || u.get() == sec_u)
return unit_weapons(rc, sec_u, rc.screen().mouseover_hex());
1291 map_location highlighted_hex = rc.screen().displayed_unit_hex();
1294 attack_loc = rc.mhb()->current_unit_attacks_from(highlighted_hex);
1296 if (!attack_loc.
valid())
1297 return unit_weapons(rc, sec_u, rc.screen().mouseover_hex());
1308 if (!sec_u || u.get() == sec_u)
return unit_weapons(rc, u.get(), u->get_location());
1310 map_location highlighted_hex = rc.screen().displayed_unit_hex();
1313 attack_loc = rc.mhb()->current_unit_attacks_from(highlighted_hex);
1315 if (!attack_loc.
valid())
1350 std::ostringstream text;
1353 const std::vector<time_of_day>& schedule = rc.
tod().
times(tod_schedule_hex);
1355 tooltip <<
_(
"Time of day schedule:") <<
" \n";
1367 int times = schedule.size();
1368 text << current + 1 <<
"/" << times;
1374 map_location mouseover_hex = rc.screen().mouseover_hex();
1395 std::string lawful_color(
"white");
1396 std::string chaotic_color(
"white");
1397 std::string liminal_color(
"white");
1400 lawful_color = (
b > 0) ?
"#0f0" :
"#f00";
1401 chaotic_color = (
b < 0) ?
"#0f0" :
"#f00";
1404 liminal_color = (l > 0) ?
"#0f0" :
"#f00";
1407 <<
_(
"Lawful units:") <<
" "
1410 <<
_(
"Chaotic units:") <<
" "
1412 <<
_(
"Liminal units:") <<
" "
1415 std::string tod_image = tod.
image;
1426 map_location mouseover_hex = rc.screen().mouseover_hex();
1449 std::string lawful_color(
"white");
1450 std::string chaotic_color(
"white");
1451 std::string liminal_color(
"white");
1454 lawful_color = (bonus > 0) ?
"green" :
"red";
1455 chaotic_color = (bonus < 0) ?
"green" :
"red";
1457 if (bonus_lim != 0) {
1458 liminal_color = (bonus_lim > 0) ?
"green" :
"red";
1461 <<
_(
"Lawful units:") <<
" "
1464 <<
_(
"Chaotic units:") <<
" "
1466 <<
_(
"Liminal units:") <<
" "
1469 std::string local_tod_image =
"themes/classic/" + local_tod.
image;
1470 std::string global_tod_image =
"themes/classic/" + global_tod.
image;
1472 local_tod_image +=
"~BLIT(";
1478 local_tod_image +=
")";
1490 std::string bg_terrain_image;
1494 bg_terrain_image =
"~BLIT(unit_env/terrain/terrain-" + terrain_id +
".png)" + bg_terrain_image;
1497 std::stringstream color;
1498 color << local_tod.
color;
1500 bg_terrain_image = bg_terrain_image +
"~CS(" + color.str() +
")";
1503 std::string unit_image;
1508 std::string tod_image = global_tod_image +
"~BLIT(" + local_tod_image +
")";
1510 return image_report(tod_image + bg_terrain_image + unit_image,
tooltip.str(),
"time_of_day");
1514 map_location mouseover_hex = rc.screen().mouseover_hex();
1521 std::ostringstream str,
tooltip;
1522 str << rc.tod().turn();
1523 int nb = rc.tod().number_of_turns();
1528 tooltip <<
"\n\n" <<
_(
"When the game exceeds the number of turns indicated by the second number, it will end.");
1535 std::ostringstream str;
1536 const team& viewing_team = rc.screen().viewing_team();
1538 int fake_gold = viewing_team.
gold();
1540 fake_gold -= rc.wb()->get_spent_gold_for(viewing_team.
side());
1543 if (!rc.screen().viewing_team_is_playing()) {
1545 }
else if (fake_gold < 0) {
1551 return text_report(str.str(),
_(
"Gold") +
"\n\n" +
_(
"The amount of gold currently available to recruit and maintain your army."));
1556 std::ostringstream str;
1557 const team &viewing_team = rc.screen().viewing_team();
1558 str << viewing_team.
villages().size() <<
'/';
1560 int unshrouded_villages = 0;
1563 ++unshrouded_villages;
1565 str << unshrouded_villages;
1567 str << rc.map().villages().size();
1569 return gray_inactive(rc,str.str(),
_(
"Villages") +
"\n\n" +
_(
"The fraction of known villages that your side has captured."));
1574 return gray_inactive(rc, std::to_string(rc.dc().side_units(rc.screen().viewing_team().side())),
_(
"Units") +
"\n\n" +
_(
"The total number of units on your side."));
1579 std::ostringstream str;
1580 const team& viewing_team = rc.screen().viewing_team();
1583 return gray_inactive(rc,str.str(),
_(
"Upkeep") +
"\n\n" +
_(
"The expenses incurred at the end of every turn to maintain your army. The first number is the amount of gold that will be deducted. It is equal to the number of unit levels not supported by villages. The second is the total cost of upkeep, including that covered by villages — in other words, the amount of gold that would be deducted if you lost all villages."));
1588 const team& viewing_team = rc.screen().viewing_team();
1595 std::ostringstream str;
1596 const team& viewing_team = rc.screen().viewing_team();
1599 if (!rc.screen().viewing_team_is_playing()) {
1613 return text_report(str.str(),
_(
"Net Income") +
"\n\n" +
_(
"The net amount of gold you gain or lose each turn, taking into account income from controlled villages and payment of upkeep."));
1617 void blit_tced_icon(
config &
cfg,
const std::string &terrain_id,
const std::string &icon_image,
bool high_res,
1618 const std::string &terrain_name) {
1619 const std::string tc_base = high_res ?
"images/buttons/icon-base-32.png" :
"images/buttons/icon-base-16.png";
1620 const std::string terrain_image =
"terrain/" + icon_image + (high_res ?
"_30.png" :
".png");
1621 add_image(
cfg, tc_base +
"~RC(magenta>" + terrain_id +
")~BLIT(" + terrain_image +
")", terrain_name);
1627 const gamemap& map = rc.map();
1628 map_location mouseover_hex = rc.screen().mouseover_hex();
1631 mouseover_hex = rc.screen().selected_hex();
1645 bool high_res =
false;
1666 if(terrain_icon.empty()) {
1669 blit_tced_icon(
cfg, terrain_id, terrain_icon, high_res, terrain_name);
1673 int owner = rc.dc().village_owner(mouseover_hex);
1677 const team& viewing_team = rc.screen().viewing_team();
1679 if(!viewing_team.
fogged(mouseover_hex)) {
1680 const team& owner_team = rc.dc().get_team(owner);
1685 std::string mods =
"~RC(" + old_rgb +
">" + new_rgb +
")";
1690 std::string side = std::to_string(owner_team.
side());
1703 const gamemap &map = rc.map();
1704 const team& viewing_team = rc.screen().viewing_team();
1705 map_location mouseover_hex = rc.screen().mouseover_hex();
1713 std::ostringstream str;
1716 int owner = rc.dc().village_owner(mouseover_hex);
1717 if (owner == 0 || viewing_team.
fogged(mouseover_hex)) {
1719 }
else if (owner == viewing_team.
side()) {
1721 }
else if (viewing_team.
is_enemy(owner)) {
1728 if(!underlying_desc.empty()) {
1729 str << underlying_desc;
1740 std::ostringstream text;
1742 std::ostringstream
help;
1744 text << static_cast<int>(rc.screen().get_zoom_factor() * 100) <<
"%";
1751 const gamemap &map = rc.map();
1752 map_location mouseover_hex = rc.screen().mouseover_hex(),
1753 displayed_unit_hex = rc.screen().displayed_unit_hex(),
1756 if (!map.
on_board(mouseover_hex)) {
1768 std::ostringstream str;
1769 str << mouseover_hex;
1772 const team &viewing_team = rc.screen().viewing_team();
1774 (displayed_unit_hex != mouseover_hex
1775 && displayed_unit_hex != rc.screen().selected_hex())
1776 || viewing_team.
shrouded(mouseover_hex))
1784 str <<
" " << defense <<
"%," << move_cost;
1785 }
else if (mouseover_hex == displayed_unit_hex) {
1786 str <<
" " << defense <<
"%,‒";
1795 const team &active_team = rc.screen().playing_team();
1799 std::string mods =
"~RC(" + old_rgb +
">" + new_rgb +
")";
1808 const std::set<std::string> &observers = rc.screen().observers();
1809 if (observers.empty())
1812 std::ostringstream str;
1813 str <<
_(
"Observers:") <<
'\n';
1814 for (
const std::string &obs : observers) {
1829 const auto now = std::chrono::system_clock::now();
1848 using namespace std::chrono_literals;
1849 const team& viewing_team = rc.screen().viewing_team();
1851 return report_report_clock(rc);
1854 std::ostringstream time_str, formatted_time_str;
1856 using std::chrono::duration_cast;
1857 #ifdef __cpp_lib_format
1858 auto sec = duration_cast<std::chrono::seconds>(viewing_team.
countdown_time());
1861 auto fmt = [](
const auto& duration) -> std::string {
1862 return formatter{} << std::setw(2) << std::setfill(
'0') << duration.count();
1866 auto sec = duration_cast<std::chrono::seconds>(viewing_team.
countdown_time());
1867 auto min = duration_cast<std::chrono::minutes>(sec);
1868 time_str << fmt(min) <<
':' << fmt(sec - min);
1872 if (!rc.screen().viewing_team_is_playing()) {
1874 }
else if (sec < 60
s) {
1875 formatted_time_str <<
span_color(
"#c80000", time_str.str());
1876 }
else if (sec < 120
s) {
1877 formatted_time_str <<
span_color(
"#c8c800", time_str.str());
1879 formatted_time_str << time_str.str();
1884 add_text(report, formatted_time_str.str(),
1885 _(
"Turn Countdown") +
"\n\n" +
_(
"Countdown until your turn automatically ends."));
1903 return iter->second->generate(rc);
1913 return std::invoke(iter->second, rc);
int generic_combat_modifier(int lawful_bonus, unit_alignments::type alignment, bool is_fearless, int max_liminal_bonus)
Returns the amount that a unit's damage should be multiplied by due to a given lawful_bonus.
int combat_modifier(const unit_map &units, const gamemap &map, const map_location &loc, unit_alignments::type alignment, bool is_fearless)
Returns the amount that a unit's damage should be multiplied by due to the current time of day.
int under_leadership(const unit &u, const map_location &loc)
Tests if the unit at loc is currently affected by leadership.
Various functions that implement attacks and attack calculations.
unsigned swarm_blows(unsigned min_blows, unsigned max_blows, unsigned hp, unsigned max_hp)
Calculates the number of blows resulting from swarm.
Computes the statistics of a battle between an attacker and a defender unit.
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(std::string_view key)
const team & get_team(int side) const
This getter takes a 1-based side number, not a 0-based team number.
const unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false) const
unit_const_ptr get_visible_unit_shared_ptr(const map_location &loc, const team ¤t_team, bool see_all=false) const
const team & viewing_team() const
const team & playing_team() const
virtual const map_location & displayed_unit_hex() const
Virtual functions shadowed in game_display.
const map_location & selected_hex() const
bool show_everything() const
static display * get_singleton()
Returns the display object if a display object exists.
bool viewing_team_is_playing() const
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
const map_location & get_attack_indicator_src()
const pathfind::marked_route & get_route()
Gets the route along which footsteps are drawn to show movement of a unit.
static game_display * get_singleton()
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Encapsulates the map of the game.
bool is_village(const map_location &loc) const
std::string get_underlying_terrain_string(const map_location &loc) const
std::string get_terrain_string(const map_location &loc) const
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
static const int UNREACHABLE
Magic value that signifies a hex is unreachable.
bool use_twelve_hour_clock_format()
const display_context & dc() const
const unit_map & units() const
const tod_manager & tod() const
const gamemap & map() const
const display & screen() const
void register_generator(const std::string &name, generator *)
std::set< std::string > all_reports_
config generate_builtin_report(const std::string &name, const context &rc)
Generate the specified report using the given context, excluding dynamic generators.
const std::set< std::string > & report_list()
std::function< config(const reports::context &)> generator_function
config generate_report(const std::string &name, const context &ct)
Generate the specified report using the given context.
dynamic_report_generators dynamic_generators_
void set_for_listing(bool for_listing)
std::vector< unit_ability_t::tooltip_info > abilities_special_tooltips(const attack_type &at, boost::dynamic_bitset<> &active_list) const
static specials_context_t make(specials_combatant &&self, specials_combatant &&other, bool attacking)
const std::string & str() const
This class stores all the data for a single 'side' (in game nomenclature).
const std::string & color() const
const std::string & side_name() const
bool is_enemy(int n) const
const std::set< map_location > & villages() const
static t_string get_side_color_name_for_UI(unsigned side)
static std::string get_side_color_id(unsigned side)
bool shrouded(const map_location &loc) const
std::chrono::milliseconds countdown_time() const
const std::string & flag_icon() const
bool fogged(const map_location &loc) const
const t_string & income_description_enemy() const
const std::string & icon_image() const
const t_string & income_description() const
const t_string & income_description_ally() const
const std::string & id() const
const t_string & description() const
const t_translation::ter_list & def_type() const
const t_translation::ter_list & union_type() const
const t_string & income_description_own() const
t_translation::terrain_code number() const
int get_max_liminal_bonus() const
const std::vector< time_of_day > & times() const
const time_of_day & get_time_of_day(int for_turn=0) const
Returns global time of day for the passed turn.
time_of_day get_illuminated_time_of_day(const unit_map &units, const gamemap &map, const map_location &loc, int for_turn=0) const
Returns time of day object for the passed turn at a location.
int get_current_time() const
const std::string & id() const
const t_string & name(GENDER gender=MALE) const
A single unit type that the player may recruit.
static std::string alignment_description(unit_alignments::type align, unit_race::GENDER gender=unit_race::MALE)
Implementation detail of unit_type::alignment_description.
bool show_variations_in_help() const
Whether the unit type has at least one help-visible variation.
This class represents a single unit of a specific type.
@ selected_hex
Image on the selected unit.
static std::string _n(const char *str1, const char *str2, int n)
static std::string _(const char *str)
bool invisible(const map_location &loc, bool see_all=true) const
std::vector< unit_ability_t::tooltip_info > ability_tooltips() const
Gets the names and descriptions of this unit's abilities.
int max_hitpoints() const
The max number of hitpoints this unit can have.
unit_alignments::type alignment() const
The alignment of this unit.
int level() const
The current level of this unit.
const t_string & type_name() const
Gets the translatable name of this unit's type.
int hitpoints() const
The current number of hitpoints this unit has.
bool get_state(const std::string &state) const
Check if the unit is affected by a status effect.
std::string small_profile() const
An optional profile image to display in Help.
const std::string & type_id() const
The id of this unit's type.
const unit_race * race() const
Gets this unit's race.
const unit_type & type() const
This unit's type, accounting for gender and variation.
int experience() const
The current number of experience points this unit has.
const std::string & id() const
Gets this unit's id.
int side() const
The side this unit belongs to.
std::vector< t_string > unit_special_notes() const
The unit's special notes.
int max_experience() const
The max number of experience points this unit can have.
unit_race::GENDER gender() const
The gender of this unit.
const t_string & name() const
Gets this unit's translatable display name.
t_string unit_description() const
A detailed description of this unit.
@ STATE_INVULNERABLE
The unit is a guardian - it won't move unless a target is sighted.
@ STATE_PETRIFIED
The unit is poisoned - it loses health each turn.
@ STATE_UNHEALABLE
The unit has not moved.
@ STATE_POISONED
The unit is slowed - it moves slower and does less damage.
std::vector< std::pair< std::string, std::string > > amla_icons() const
Gets the image and description data for modification advancements.
bool can_advance() const
Checks whether this unit has any options to advance to.
std::map< std::string, std::string > advancement_icons() const
Gets and image path and and associated description for each advancement option.
int resistance_against(const std::string &damage_name, bool attacker, const map_location &loc) const
The unit's resistance against a given damage type.
attack_itors attacks()
Gets an iterator over this unit's attacks.
int defense_modifier(const t_translation::terrain_code &terrain, const map_location &loc) const
The unit's defense on a given terrain.
utils::string_map_res get_base_resistances() const
Gets resistances without any abilities applied.
int max_attacks() const
The maximum number of attacks this unit may perform per turn, usually 1.
int attacks_left() const
Gets the remaining number of attacks this unit can perform this turn.
color_t xp_color() const
Color for this unit's XP.
color_t hp_color() const
Color for this unit's current hitpoints.
std::string image_mods() const
Gets an IPF string containing all IPF image mods.
std::string absolute_image() const
The name of the file to game_display (used in menus).
int jamming() const
Gets the unit's jamming points.
const map_location & get_location() const
The current map location this unit is at.
int movement_cost(const t_translation::terrain_code &terrain) const
Get the unit's movement cost on a particular terrain.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
int total_movement() const
The maximum moves this unit has.
int vision() const
Gets the unit's vision points.
std::vector< std::string > trait_nonhidden_ids() const
Gets the ids of the traits corresponding to those returned by trait_names() and trait_descriptions().
bool is_fearless() const
Gets whether this unit is fearless - ie, unaffected by time of day.
const std::vector< t_string > & trait_descriptions() const
Gets the descriptions of the currently registered traits.
const std::vector< t_string > & trait_names() const
Gets the names of the currently registered traits.
std::string tooltip
Shown when hovering over an entry in the filter's drop-down list.
constexpr int round_damage(double base_damage, int bonus, int divisor)
round (base_damage * bonus / divisor) to the closest integer, but up or down towards base_damage
auto format_local_timestamp(const std::chrono::system_clock::time_point &time, std::string_view format="%F %T")
double get_battery_percentage()
void line(int from_x, int from_y, int to_x, int to_y)
Draw a line.
const std::string weapon_details_sep
std::string escape_text(std::string_view text)
Escapes the pango markup characters in a text.
const std::string unicode_bullet
const color_t weapon_details_color
const color_t good_dmg_color
const std::string unicode_en_dash
const color_t weapon_color
const std::string unicode_figure_dash
const color_t INACTIVE_COLOR
const std::string weapon_numbers_sep
const std::string unicode_minus
const color_t bad_dmg_color
color_t blue_to_white(double val, bool for_text)
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 get_unit_type_help_id(const unit_type &t)
Given a unit type, find the corresponding help topic's id.
Functions to load and save images from/to disk.
bool exists(const image::locator &i_locator)
Returns true if the given image actually exists, without loading it.
std::string italic(Args &&... data)
Applies italic Pango markup to the input.
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.
std::string tag(std::string_view tag, Args &&... data)
Wraps the given data in the specified tag.
static std::string at(const std::string &file, int line)
const terrain_code VOID_TERRAIN
VOID_TERRAIN is used for shrouded hexes.
bool terrain_matches(const terrain_code &src, const terrain_code &dest)
Tests whether a specific terrain matches an expression, for matching rules see above.
std::vector< terrain_code > ter_list
const ter_match ALL_OFF_MAP
const terrain_code FOGGED
static std::string gettext(const char *str)
static std::string unit_level_tooltip(const int level, const std::vector< std::string > &adv_to_types, const std::vector< config > &adv_to_mods)
std::string resistance_color(const int resistance)
Maps resistance <= -60 (resistance value <= -60%) to intense red.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
std::string half_signed_value(int val)
Sign with Unicode "−" if negative.
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::string signed_value(int val)
Convert into a signed value (using the Unicode "−" and +0 convention.
std::string signed_percent(int val)
Convert into a percentage (using the Unicode "−" and +0% convention.
@ enemy
Belongs to a non-friendly side; normally visualised by not displaying an orb.
This module contains various pathfinding functions and utilities.
std::shared_ptr< const unit > unit_const_ptr
std::shared_ptr< const attack_type > const_attack_ptr
static config unit_name(const unit *u)
static config image_report(const std::string &image, const std::string &tooltip="", const std::string &help="")
static std::string flush(std::ostringstream &s)
static void add_image(config &report, const std::string &image, const std::string &tooltip, const std::string &help="")
static config unit_hp(const reports::context &rc, const unit *u)
static config unit_type(const unit *u)
static std::string side_tooltip(const team &team)
static config unit_jamming(const unit *u)
static const unit * get_visible_unit(const reports::context &rc)
static config tod_stats_at(const reports::context &rc, const map_location &hex)
static unit_const_ptr get_selected_unit_ptr(const reports::context &rc)
static int attack_info(const reports::context &rc, const attack_type &at, config &res, const unit &u, const map_location &hex, const unit *sec_u=nullptr, const const_attack_ptr &sec_u_weapon=nullptr)
std::map< std::string, reports::generator_function > static_report_generators
static config unit_side(const reports::context &rc, const unit *u)
static config unit_defense(const reports::context &rc, const unit *u, const map_location &displayed_unit_hex)
static std::string format_prob(double prob)
static config unit_status(const reports::context &rc, const unit *u)
static config gray_inactive(const reports::context &rc, const std::string &str, const std::string &tooltip="")
static static_report_generators static_generators
static config unit_level(const unit *u)
static config unit_vision(const unit *u)
static const color_t attack_info_percent_color(int resistance)
Maps resistance <= -60 (resistance value <= -60%) to intense red.
static config unit_traits(const unit *u)
static config unit_abilities_report(const unit *u, const map_location &loc)
static config unit_box_at(const reports::context &rc, const map_location &mouseover_hex)
static const time_of_day get_visible_time_of_day_at(const reports::context &rc, const map_location &hex)
static config unit_race(const unit *u)
static void add_text(config &report, const std::string &text, const std::string &tooltip, const std::string &help="")
static config time_of_day_at(const reports::context &rc, const map_location &mouseover_hex)
static config unit_weapons(const reports::context &rc, const unit_const_ptr &attacker, const map_location &attacker_pos, const unit *defender, bool show_attacker)
#define REPORT_GENERATOR(n, cn)
static config text_report(const std::string &text, const std::string &tooltip="", const std::string &help="")
static config unit_moves(const reports::context &rc, const unit *u, bool is_visible_unit)
static config unit_alignment(const reports::context &rc, const unit *u, const map_location &hex)
static void add_status(config &r, const std::string &path, char const *desc1, char const *desc2)
static const unit * get_selected_unit(const reports::context &rc)
static std::string format_hp(unsigned hp)
static config unit_advancement_options(const unit *u)
static config unit_xp(const unit *u)
Structure describing the statistics of a unit involved in the battle.
unsigned int num_blows
Effective number of blows, takes swarm into account.
const_attack_ptr weapon
The weapon used by the unit to attack the opponent, or nullptr if there is none.
int damage
Effective damage of the weapon (all factors accounted for).
unsigned int chance_to_hit
Effective chance to hit as a percentage (all factors accounted for).
The basic class for representing 8-bit RGB or RGBA colour values.
void fight(combatant &opponent, bool levelup_considered=true)
Simulate a fight! Can be called multiple times for cumulative calculations.
Encapsulates the map of the game.
static const map_location & null_location()
Structure which holds a single route and marks for special events.
std::vector< map_location > & steps
report_generator_helper(const char *name, const reports::generator_function &g)
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
Object which defines a time of day with associated bonuses, image, sounds etc.
tod_color color
The color modifications that should be made to the game board to reflect the time of day.
int lawful_bonus
The % bonus lawful units receive.
std::string image
The image to be displayed in the game status.
static int get_acceleration()
static map_location::direction s