56 char output_text[
O_LAST][16];
58 for (i = 0; i <
O_LAST; i++) {
59 int before_penalty = 0;
67 EFT_OUTPUT_PENALTY_TILE);
70 if (before_penalty > 0 && x > before_penalty) {
71 fc_snprintf(output_text[i],
sizeof(output_text[i]),
"%d(-1)", x);
73 fc_snprintf(output_text[i],
sizeof(output_text[i]),
"%d", x);
77 str = QStringLiteral(
"%1/%2/%3")
81 return qUtf8Printable(str);
89 const struct player *pplayer)
91 if (!buf || buflen < 1) {
100 if (
is_ai(pplayer)) {
113 const struct player *pplayer)
115 if (!buf || buflen < 1) {
139 QString activity_text;
142 const char *diplo_nation_plural_adjectives[DS_LAST] = {
143 "" ,
Q_(
"?nation:Hostile"),
144 "" ,
Q_(
"?nation:Peaceful"),
145 Q_(
"?nation:Friendly"),
Q_(
"?nation:Mysterious"),
146 Q_(
"?nation:Friendly(team)")};
147 const char *diplo_city_adjectives[DS_LAST] = {
148 "" ,
Q_(
"?city:Hostile"),
149 "" ,
Q_(
"?city:Peaceful"),
150 Q_(
"?city:Friendly"),
Q_(
"?city:Mysterious"),
151 Q_(
"?city:Friendly(team)")};
159 str = QString(
_(
"Location: (%1, %2) [%3]\n"))
160 .arg(QString::number(tile_x), QString::number(tile_y),
163 str += QString(
_(
"Native coordinates: (%1, %2)\n"))
164 .arg(QString::number(
nat_x), QString::number(
nat_y));
167 str += QString(
_(
"Unknown"));
168 return str.trimmed();
177 if (pextra->category == ECAT_BONUS
196 str += QString(
_(
"Our territory")) +
qendl();
201 }
else if (
nullptr != owner) {
205 if (ds->
type == DS_CEASEFIRE) {
210 QString(
PL_(
"Territory of %1 (%2) (%3 turn cease-fire)",
211 "Territory of %1 (%2) (%3 turn cease-fire)", turns))
212 .arg(username, nation, QString::number(turns))
214 }
else if (ds->
type == DS_ARMISTICE) {
219 QString(
PL_(
"Territory of %1 (%2) (%3 turn armistice)",
220 "Territory of %1 (%2) (%3 turn armistice)", turns))
221 .arg(username, nation, QString::number(turns))
228 QString(
_(
"Territory of %1 (%2 | %3)"))
229 .arg(username, nation, diplo_nation_plural_adjectives[
type])
233 str += QString(
_(
"Unclaimed territory")) +
qendl();
248 str += QString(
_(
"City: %1 | %2 (%3)"))
254 if (ds->
type == DS_CEASEFIRE) {
259 str += QString(
PL_(
"City: %1 | %2 (%3, %4 turn cease-fire)",
260 "City: %1 | %2 (%3, %4 turn cease-fire)", turns))
262 QString::number(turns))
265 }
else if (ds->
type == DS_ARMISTICE) {
270 str += QString(
PL_(
"City: %1 | %2 (%3, %4 turn armistice)",
271 "City: %1 | %2 (%3, %4 turn armistice)", turns))
273 QString::number(turns))
278 str += QString(
_(
"City: %1 | %2 (%3, %4)"))
280 diplo_city_adjectives[ds->
type])
285 int count = unit_list_size(ptile->
units);
289 str += QString(
PL_(
" | Occupied with %1 unit.",
290 " | Occupied with %2 units.", count))
291 .arg(QString::number(count));
294 str += QString(
_(
" | Not occupied."));
299 str += QString(
_(
" | Occupied."));
302 str += QString(
_(
" | Not occupied."));
314 if (!improvements.isEmpty()) {
327 str += QString(
_(
"Trade from %1: %2"))
338 if (*infratext !=
'\0') {
339 str += QString(
_(
"Infrastructure: %1")).arg(infratext) +
qendl();
343 if (activity_text.length() > 0) {
344 str += QString(
_(
"Activity: %1")).arg(activity_text) +
qendl();
346 if (punit && !pcity) {
357 str +=
_(
"Can move in ") + QString(buf) +
qendl();
361 if (punit->
name.isEmpty()) {
377 str += QString(
_(
"Unit: %1 | %2 (%3)"))
385 if (hcity !=
nullptr) {
389 QString(
_(
"from %1 | %2 people"))
397 QString(
_(
"%1 people"))
401 }
else if (hcity !=
nullptr) {
405 }
else if (
nullptr !=
owner) {
408 if (ds->
type == DS_CEASEFIRE) {
413 str += QString(
PL_(
"Unit: %1 | %2 (%3, %4 turn cease-fire)",
414 "Unit: %1 | %2 (%3, %4 turn cease-fire)", turns))
416 QString::number(turns))
418 }
else if (ds->
type == DS_ARMISTICE) {
423 str += QString(
PL_(
"Unit: %1 | %2 (%3, %4 turn armistice)",
424 "Unit: %1 | %2 (%3, %4 turn armistice)", turns))
426 QString::number(turns))
431 str += QString(
_(
"Unit: %1 | %2 (%3, %4)"))
433 diplo_city_adjectives[ds->
type])
451 att_chance =
MIN(att, att_chance);
452 def_chance =
MIN(def, def_chance);
459 str += QString(
_(
"Chance to win: A:%1% D:%2%"))
460 .arg(QString::number(att_chance),
461 QString::number(def_chance))
467 QString mp_left =
_(
"?");
475 nullptr,
nullptr,
false);
476 str += QString(
_(
"A:%1 D:%2 FP:%3 HP:%4/%5 MP:%6 of %7"))
480 QString::number(punit->
hp), QString::number(ptype->
hp),
483 const char *veteran_name =
486 str += QStringLiteral(
" (%1)").arg(veteran_name);
492 str +=
_(
"Bribing not possible.") +
qendl();
496 str += QString(
_(
"Probable bribe cost: %1"))
502 QString(
_(
"Estimated bribe cost: > %1"))
508 && unit_list_size(ptile->
units) >= 2) {
510 str += QString(
_(
" (%1 more)"))
511 .arg(QString::number(unit_list_size(ptile->
units) - 1));
515 return str.trimmed();
518 #define FAR_CITY_SQUARE_DIST (2 * (6 * 6))
541 return str.trimmed();
561 const char *veteran_name =
564 str += QStringLiteral(
"( %1)").arg(veteran_name);
567 if (pplayer == owner) {
580 if (
game.
info.citizen_nationality) {
581 if (nationality !=
nullptr && owner != nationality) {
584 str += QString(
_(
"%1 people"))
591 str += QStringLiteral(
"%1").arg(
595 str += QStringLiteral(
"Unit ID: %1").arg(punit->
id);
598 return str.trimmed();
613 const struct city *pdest)
616 bool src = (pdest ==
nullptr);
622 } best = AL_IMPOSSIBLE;
623 int cur = 0, max = 0;
625 for (
const auto punit :
units) {
626 enum texttype tthis = AL_IMPOSSIBLE;
640 tthis = AL_IMPOSSIBLE;
654 && (
game.
info.airlifting_style & AIRLIFTING_UNLIMITED_DEST)) {
664 tthis = AL_IMPOSSIBLE;
667 && (
game.
info.airlifting_style & AIRLIFTING_UNLIMITED_SRC)) {
675 if (best == AL_FINITE) {
676 fc_assert(cur == this_cur && max == this_max);
691 best =
MAX(best, tthis);
698 str = QStringLiteral(
"?");
701 str = QStringLiteral(
"%1/%2").arg(cur, max);
708 return str.trimmed();
717 int ours = 0, theirs = 0;
736 theirs -= pplayer->client.tech_upkeep;
742 theirs += presearch->
client.total_bulbs_prod - ours;
755 return ours + theirs;
766 if (missing <= per_turn) {
769 }
else if (per_turn > 0) {
770 return std::ceil(
static_cast<double>(missing) / per_turn);
784 ceil((
double) presearch->
client.researching_cost) / per_turn);
796 if (per_turn >= 0 ||
game.
info.techloss_forgiveness == -1) {
802 + (presearch->
client.researching_cost
803 *
game.
info.techloss_forgiveness / 100);
805 return ceil(
static_cast<double>(bulbs_to_loss) / -per_turn);
815 int ours, theirs, perturn, upkeep;
816 QString str, ourbuf, theirbuf;
825 || (ours == 0 && theirs == 0 && upkeep == 0)) {
826 return _(
"Progress: no research");
830 str =
_(
"Progress: no research");
835 str += QString(
PL_(
"Progress: %1 turn/advance",
836 "Progress: %1 turns/advance", turns))
841 str += QString(
PL_(
"Progress: %1 turn/advance loss",
842 "Progress: %1 turns/advance loss", turns))
847 str += QString(
_(
"Progress: decreasing!"));
849 str += QString(
_(
"Progress: none"));
853 ourbuf = QString(
PL_(
"%1 bulb/turn",
"%1 bulbs/turn", ours)).arg(ours);
856 theirbuf = QString(
PL_(
", %1 bulb/turn from team",
857 ", %1 bulbs/turn from team", theirs))
860 theirbuf = QLatin1String(
"");
862 str += QStringLiteral(
" (%1%2)").arg(ourbuf, theirbuf);
864 if (
game.
info.tech_upkeep_style != TECH_UPKEEP_NONE) {
867 str += QString(
_(
"Bulbs produced per turn: %1"))
868 .arg(QString::number(perturn + upkeep));
871 str += QString(
_(
" (needed for technology upkeep: %1)"))
872 .arg(QString::number(upkeep));
875 return str.trimmed();
893 return QStringLiteral(
"-");
897 str = QString(
_(
"%1/- (never)"))
906 str = QString(
PL_(
"%1/%2 (%3 turn)",
"%1/%2 (%3 turns)", turns))
907 .arg(QString::number(done), QString::number(total),
908 QString::number(turns));
910 str = QString(
PL_(
"%1/%2 (%3 turn to loss)",
911 "%1/%2 (%3 turns to loss)", turns))
912 .arg(QString::number(done), QString::number(total),
913 QString::number(turns));
916 str = QString(
_(
"%1/%2 (never)"))
917 .arg(QString::number(done), QString::number(total));
921 return str.trimmed();
931 return QStringLiteral(
"-");
953 if (bulbs_needed < perturn) {
955 }
else if (perturn > 0) {
956 turns = (bulbs_needed + perturn - 1) / perturn;
959 QString buf1, buf2, buf3;
961 QString(
PL_(
"%1 step",
"%1 steps", steps)).arg(QString::number(steps));
962 buf2 = QString(
PL_(
"%1 bulb",
"%1 bulbs", bulbs_needed))
963 .arg(QString::number(bulbs_needed));
966 buf3 = QString(
PL_(
"%1 turn",
"%1 turns", turns))
967 .arg(QString::number(turns));
969 buf3 = QString(
_(
"never"));
972 return QStringLiteral(
"(%1 - %2 - %3)").arg(buf1, buf2, buf3);
986 str = QString(
_(
"Population: %1"))
990 str += QString(
_(
"Year: %1 (T%2)"))
995 str += QString(
_(
"Gold: %1 (%2)"))
1000 str += QString(
_(
"Tax: %1 Lux: %2 Sci: %3"))
1006 if (
game.
info.phase_mode == PMT_PLAYERS_ALTERNATE) {
1008 str += QString(
_(
"Moving: Nobody")) +
qendl();
1010 str += QString(
_(
"Moving: %1"))
1014 }
else if (
game.
info.phase_mode == PMT_TEAMS_ALTERNATE) {
1016 str += QString(
_(
"Moving: Nobody")) +
qendl();
1018 str += QString(
_(
"Moving: %1"))
1025 str += QString(
_(
"(Click for more info)")) +
qendl();
1028 return str.trimmed();
1041 str = QString(
_(
"%1 People"))
1047 QString(
_(
"Turn: %1")).arg(QString::number(
game.
info.turn)) +
qendl();
1054 str += QString(
_(
"Gold: %1"))
1057 str += QString(
_(
"Net Income: %1"))
1058 .arg(QString::number(
1062 str += QString(
_(
"National budget: Gold:%1% Luxury:%2% Science:%3%"))
1068 str += QString(
_(
"Researching %1: %2"))
1074 if (
game.
info.tech_upkeep_style != TECH_UPKEEP_NONE) {
1075 str += QString(
_(
"Bulbs per turn: %1 - %2 = %3"))
1076 .arg(QString::number(perturn + upkeep),
1077 QString::number(upkeep), QString::number(perturn))
1081 str += QString(
_(
"Bulbs per turn: %1")).arg(QString::number(perturn))
1091 str += QString(
_(
"Culture: %1 (%2/turn)"))
1093 QString::number(history_perturn))
1101 str += QString(
_(
"Global warming chance: %1% (%2%/turn)"))
1102 .arg(QString::number(chance), QString::number(rate))
1105 str += QString(
_(
"Global warming deactivated.")) +
qendl();
1111 str += QString(
_(
"Nuclear winter chance: %1% (%2%/turn)"))
1112 .arg(QString::number(chance), QString::number(rate))
1115 str += QString(
_(
"Nuclear winter deactivated.")) +
qendl();
1119 str += QString(
_(
"Government: %1"))
1124 return str.trimmed();
1133 const std::vector<unit *> &punits)
1135 if (punits.empty()) {
1138 }
else if (punits.size() == 1) {
1141 int upgrade_cost = 0;
1142 int num_upgraded = 0;
1145 for (
const auto punit : punits) {
1155 upgrade_cost += cost;
1156 min_upgrade_cost =
MIN(min_upgrade_cost, cost);
1159 if (num_upgraded == 0) {
1160 fc_snprintf(buf, bufsz,
_(
"None of these units may be upgraded."));
1170 PL_(
"Treasury contains %d gold.",
1171 "Treasury contains %d gold.",
1178 PL_(
"Upgrade %d unit",
"Upgrade %d units", num_upgraded),
1186 PL_(
"%s for %d gold?\n%s",
"%s for %d gold?\n%s", upgrade_cost),
1187 ubuf, upgrade_cost, tbuf);
1204 memset(&ship, 0,
sizeof(ship));
1207 str += QString(
_(
"Population: %1"))
1211 str += QString(
_(
"Support: %1 %"))
1212 .arg(QString::number(
1217 QString(
_(
"Energy: %1 %"))
1218 .arg(QString::number(
static_cast<int>(pship->
energy_rate * 100.0)))
1221 str += QString(
PL_(
"Mass: %1 ton",
"Mass: %1 tons",
1223 .arg(QString::number(pship->
mass))
1227 str += QString(
_(
"Travel time: %1 years"))
1228 .arg(QString::number(
static_cast<float>(
1229 0.1 * (
static_cast<int>(pship->
travel_time * 10.0)))))
1233 str += QStringLiteral(
"%1").arg(
_(
"Travel time: N/A "))
1237 str += QString(
_(
"Success prob.: %1 %"))
1238 .arg(QString::number(
1242 str += QString(
_(
"Year of arrival: %1"))
1249 return str.trimmed();
1262 str = QStringLiteral(
"%1").arg(QString::number(pplayer->
score.
game));
1264 str = QStringLiteral(
"?");
1267 return str.trimmed();
1276 const struct unit *actor_unit,
1277 const struct city *target_city)
1287 || target_city !=
nullptr),
1298 _(
"%1 one time bonus + %2 trade"))
1299 .arg(QString::number(revenue),
1301 actor_homecity, target_city)));
1310 _(
"%1 one time bonus"))
1311 .arg(QString::number(revenue));
1318 custom = QString(
_(
"%1 remaining"))
1319 .arg(QString::number(cost - target_city->
shield_stock));
1345 QString text_happiness_effect_details(
const city *pcity, effect_type
effect)
1347 auto effects = effect_list_new();
1352 "The following contribution is active:",
1353 "The following contributions are active:", effect_list_size(
effects));
1354 str += QStringLiteral(
"<ul>");
1360 str += QStringLiteral(
"<li>");
1361 if (requirement_vector_size(&peffect->reqs) == 0) {
1363 str += QString(
_(
"%1 by default"))
1366 help_text_buffer[0] =
'\0';
1368 sizeof(help_text_buffer));
1370 str += QString(
_(
"%1 from %2"))
1372 .arg(help_text_buffer);
1374 str += QStringLiteral(
"</li>");
1379 str += QStringLiteral(
"</ul>");
1392 effect_list_size(
effects) == 0) {
1396 auto str = QStringLiteral(
"<p>");
1397 str +=
_(
"Infrastructure can have an effect on citizen happiness.");
1398 str += QStringLiteral(
" ");
1404 str +=
_(
"This city doesn't receive any such bonus.");
1405 return str + QStringLiteral(
"</p>");
1412 PL_(
"In this city, it can make up to <b>%1 citizen<b> content.",
1413 "In this city, it can make up to <b>%1 citizens<b> content.",
1418 str += QStringLiteral(
"</p><p>");
1419 str += text_happiness_effect_details(pcity, EFT_MAKE_CONTENT);
1421 return str + QStringLiteral(
"</ul></p>");
1435 auto str = QStringLiteral(
"<p>");
1437 _(
"The presence of enemy citizens can create additional unhappiness.");
1438 str += QStringLiteral(
" ");
1442 str +=
_(
"However, it is not the case in this city.");
1443 return str + QStringLiteral(
"</p>");
1447 int num = std::ceil(100. / pct);
1448 str += QString(
PL_(
"For every %1 citizen of an enemy nation, one citizen "
1450 "For every %1 citizens of an enemy nation, one citizen "
1454 str += QStringLiteral(
"</p><p>");
1461 enemies += nationality;
1467 str +=
_(
"There is <b>no enemy citizen</b> in this city.");
1469 auto unhappy = enemies * pct / 100;
1473 QString(
PL_(
"There is %1 enemy citizen in this city, ",
1474 "There are %1 enemy citizens in this city, ", enemies))
1478 str += QString(
PL_(
"resulting in <b>%1 additional unhappy citizen.</b>",
1479 "resulting in <b>%1 additional unhappy citizens.</b>",
1484 return str + QStringLiteral(
"</p>");
1492 int effects_count = effect_list_size(
get_effects(EFT_MAKE_HAPPY))
1494 + effect_list_size(
get_effects(EFT_FORCE_CONTENT));
1495 if (effects_count == 0) {
1500 auto str = QStringLiteral(
"<p>");
1501 bool wrote_something =
false;
1504 if (happy_bonus > 0) {
1505 if (happy_bonus == 1) {
1506 str +=
_(
"Up to one content citizen in this city can be made happy.");
1510 PL_(
"Up to %1 unhappy or content citizen in this city can be "
1511 "made happy (unhappy citizens count double).",
1512 "Up to %1 unhappy or content citizens in this city "
1513 "can be made happy (unhappy citizens count double).",
1519 str += QStringLiteral(
"</p><p>");
1520 str += text_happiness_effect_details(pcity, EFT_MAKE_HAPPY);
1521 str += QStringLiteral(
"</p><p>");
1522 wrote_something =
true;
1526 str +=
_(
"No citizens in this city can ever be unhappy or angry. "
1527 "Any unhappy or angry citizen are automatically made content.");
1530 str += QStringLiteral(
"</p><p>");
1532 QString(
PL_(
"Up to %1 unhappy or angry citizen in this city can be "
1534 "Up to %1 unhappy or angry citizens in this city can be "
1540 str += QStringLiteral(
"</p><p>");
1541 str += text_happiness_effect_details(pcity, EFT_FORCE_CONTENT);
1542 wrote_something =
true;
1545 if (!wrote_something) {
1547 str +=
_(
"Happiness is currently not changed at this stage.");
1550 return str + QStringLiteral(
"</p>");
1558 QString text_happiness_cities_rules(
const player *pplayer,
int base_content,
1559 int basis,
int step,
1560 bool depends_on_empire_size)
1562 auto str = QString();
1564 bool next_citizens_are_angry =
false;
1565 if (base_content == 0) {
1566 str +=
_(
"All cities start with all citizens unhappy.");
1567 next_citizens_are_angry =
game.
info.angrycitizen;
1569 str += QString(
PL_(
"All cities start with %1 content citizen.",
1570 "All cities start with %1 content citizens.",
1574 if (depends_on_empire_size) {
1576 str += QStringLiteral(
" ");
1577 if (next_citizens_are_angry) {
1578 str += QString(
PL_(
"Once you have more than %1 city, a citizen "
1580 "Once you have more than %1 cities, a citizen "
1584 }
else if (base_content == 1) {
1589 PL_(
"Once you have more than %1 city, it becomes unhappy.",
1590 "Once you have more than %1 cities, it becomes unhappy.",
1593 next_citizens_are_angry =
game.
info.angrycitizen;
1594 }
else if (base_content > 1) {
1596 str += QString(
PL_(
"Once you have more than %1 city, a citizen "
1598 "Once you have more than %1 cities, a citizen "
1606 str += QStringLiteral(
" ");
1607 if (next_citizens_are_angry) {
1608 str += QString(
PL_(
"Afterwards, for every %1 additional city, a "
1609 "citizen becomes angry.",
1610 "Afterwards, for every %1 additional cities, a "
1611 "citizen becomes angry.",
1615 str += QString(
PL_(
"Afterwards, for every %1 additional city, a "
1616 "content citizen becomes unhappy.",
1617 "Afterwards, for every %1 additional cities, a "
1618 "content citizen becomes unhappy.",
1623 str += QStringLiteral(
" ");
1624 str +=
_(
"If there are no more content citizens, an unhappy "
1625 "citizen becomes angry instead.");
1636 QString text_happiness_cities_apply_rules(
int cities,
int max_content)
1638 if (max_content > 0) {
1640 return QString(
PL_(
"You have %1 cities, resulting in a maximum of %2 "
1642 "You have %1 cities, resulting in a maximum of %2 "
1643 "content citizens.",
1647 }
else if (max_content == 0) {
1648 return QString(
PL_(
"You have %1 city, thus all citizens are unhappy.",
1649 "You have %1 cities, thus all citizens are unhappy.",
1654 return QString(
PL_(
"You have %1 cities, resulting in a maximum of "
1655 "%2 angry citizen.",
1656 "You have %1 cities, resulting in a maximum of "
1657 "%2 angry citizens.",
1667 QString text_happiness_cities_content(
int size,
int max_content)
1669 if (max_content >=
size) {
1671 return QString(
_(
"In this city of size %1, <b>all citizens are "
1674 }
else if (max_content > 0) {
1678 PL_(
"In this city of size %1, <b>%2 citizen is content.</b>",
1679 "In this city of size %1, <b>%2 citizens are "
1684 }
else if (max_content == 0) {
1687 "In this city of size %1, <b>all citizens are unhappy.</b>")
1689 }
else if (-max_content <
size) {
1694 "In this city of size %1, <b>%2 citizen is angry.</b>",
1695 "In this city of size %1, <b>%2 citizens are angry.</b>",
1702 _(
"In this city of size %1, <b>all citizens are angry.</b>"))
1711 QString text_happiness_more_cities(
int base_content,
int basis,
int step,
1716 int content = std::min<int>(max_content,
size);
1717 if (!
game.
info.angrycitizen && content < 0) {
1722 int unhappy_for_next_threshold = base_content - content + 1;
1724 int cities_to_next_threshold =
1725 basis + (unhappy_for_next_threshold - 1) *
step + 1;
1727 cities_to_next_threshold -=
cities;
1729 if (cities_to_next_threshold > 0) {
1731 return QString(
PL_(
"With %1 more city, a content citizen would become "
1733 "With %1 more cities, a content citizen would "
1735 cities_to_next_threshold))
1736 .arg(QString::number(cities_to_next_threshold));
1737 }
else if (
game.
info.angrycitizen) {
1741 PL_(
"With %1 more city, a citizen would become angry.",
1742 "With %1 more cities, a citizen would become angry.",
1743 cities_to_next_threshold))
1744 .arg(QString::number(cities_to_next_threshold));
1747 return _(
"Having more cities would not create more unhappiness.");
1761 bool depends_on_empire_size = (basis +
step > 0);
1763 while (depends_on_empire_size && basis <= 0) {
1772 depends_on_empire_size =
false;
1778 auto str = QStringLiteral(
"<p>");
1779 str += text_happiness_cities_rules(pplayer, base_content, basis,
step,
1780 depends_on_empire_size);
1783 str += QStringLiteral(
"</p><p>");
1790 if (depends_on_empire_size) {
1791 str += text_happiness_cities_apply_rules(
cities, max_content);
1795 str += QStringLiteral(
" ");
1796 str += text_happiness_cities_content(
size, max_content);
1799 if (depends_on_empire_size) {
1800 str += QStringLiteral(
" ");
1801 str += text_happiness_more_cities(base_content, basis,
step, max_content,
1805 return str + QStringLiteral(
"</p>");
1813 auto str = QString();
1818 int martial_law_max =
get_city_bonus(pcity, EFT_MARTIAL_LAW_MAX);
1819 int martial_law_each =
get_city_bonus(pcity, EFT_MARTIAL_LAW_EACH);
1820 if (martial_law_each > 0 && martial_law_max >= 0) {
1821 str += QStringLiteral(
"<p>");
1823 if (martial_law_max == 0) {
1824 str +=
_(
"Every military unit in the city may impose martial law.");
1827 QString(
PL_(
"%1 military unit in the city may impose martial law.",
1828 "Up to %1 military units in the city may impose "
1831 .arg(martial_law_max);
1834 str += QStringLiteral(
" ");
1835 str += QString(
PL_(
"Each of them makes %1 unhappy citizen content.",
1836 "Each of them makes %1 unhappy citizens content.",
1838 .arg(martial_law_each);
1840 str += QStringLiteral(
"</p><p>");
1845 if ((count < martial_law_max || martial_law_max == 0)
1854 QString(
PL_(
"%1 military unit in this city imposes the martial law.",
1855 "%1 military units in this city impose the martial law.",
1858 str += QStringLiteral(
" ");
1859 str += QString(
PL_(
"<b>%1 citizen</b> is made happier as a result.",
1860 "<b>%1 citizens</b> are made happier as a result.",
1861 count * martial_law_each))
1862 .arg(count * martial_law_each);
1864 str += QStringLiteral(
"</p>");
1873 str += QStringLiteral(
"<p>");
1877 if (unhappy_factor == 0) {
1878 str +=
_(
"Military units have no happiness effect.");
1879 return str + QStringLiteral(
"</p>");
1882 str +=
_(
"Military units in the field may cause unhappiness.");
1886 if (made_content > 0) {
1887 str += QStringLiteral(
" ");
1888 str += QString(
PL_(
"With respect to normal, %1 fewer citizen will be "
1889 "unhappy about military units.",
1890 "With respect to normal, %1 fewer citizens will be "
1891 "unhappy about military units.",
1899 int made_content_each =
get_city_bonus(pcity, EFT_MAKE_CONTENT_MIL_PER);
1900 if (made_content_each > 0) {
1901 str += QStringLiteral(
" ");
1902 str += QString(
PL_(
"With respect to normal, %1 fewer citizen will be "
1903 "unhappy per each military unit.",
1904 "With respect to normal, %1 fewer citizens will be "
1905 "unhappy per each military unit.",
1907 .arg(made_content_each);
1911 int count = 0, happy_upkeep = 0;
1922 str += QStringLiteral(
"</p><p>");
1926 str += QString(
PL_(
"This city supports %1 agressive military unit, ",
1927 "This city supports %1 agressive military units, ",
1934 PL_(
"resulting in up to <b>%1 additional unhappy citizen.</b>",
1935 "resulting in up to <b>%1 additional unhappy citizens.</b>",
1939 str +=
_(
"Currently, military units do not cause additional unhappiness "
1943 return str + QStringLiteral(
"</p>");
1951 auto str = QStringLiteral(
"<p>");
1954 str += QString(
_(
"For each %1 luxury good produced in a city, a citizen "
1955 "becomes happier."))
1957 str += QStringLiteral(
" ");
1962 if (luxuries == 0) {
1963 str +=
_(
"This city generates no luxury goods.");
1964 return str + QStringLiteral(
"</p>");
1965 }
else if (luxuries <
game.
info.happy_cost) {
1966 str += QString(
PL_(
"This city generates a total of %1 luxury good, not "
1967 "enough to have an effect.",
1968 "This city generates a total of %1 luxury goods, not "
1969 "enough to have an effect.",
1972 return str + QStringLiteral(
"</p>");
1975 str += QString(
PL_(
"This city generates a total of %1 luxury good.",
1976 "This city generates a total of %1 luxury goods.",
1980 str += QStringLiteral(
"</p><p>");
1988 int citizens_affected = std::max(0, made_happy) + std::max(0, made_content)
1989 + std::max(0, made_unhappy);
1990 int upgrades = made_happy * 3 + made_content * 2 + made_unhappy * 1;
1991 int cost = upgrades *
game.
info.happy_cost;
1993 if (cost < luxuries) {
1995 QString(
PL_(
"%1 citizen is made happier using %2 luxury good(s).",
1996 "%1 citizens are made happier using %2 luxury good(s).",
1998 .arg(citizens_affected)
2000 if (luxuries - cost > 0) {
2001 str += QStringLiteral(
" ");
2002 str += QString(
PL_(
"%1 luxury good is not used.",
2003 "%1 luxury goods are not used.", luxuries - cost))
2004 .arg(luxuries - cost);
2007 str += QString(
PL_(
"All available luxury goods are used to make %1 "
2009 "All available luxury goods are used to make %1 "
2010 "citizens happier.",
2012 .arg(citizens_affected);
2015 return str + QStringLiteral(
"</p>");
bool action_prob_possible(const struct act_prob probability)
Returns TRUE iff the given action probability belongs to an action that may be possible.
const QString action_prob_explain(const struct act_prob prob)
Explain an action probability in a way suitable for a tool tip for the button that starts it.
enum action_target_kind action_get_target_kind(const struct action *paction)
Get the target kind of an action.
bool action_has_result(const struct action *paction, enum action_result result)
Returns TRUE iff performing the specified action has the specified result.
bool is_action_possible_on_unit(action_id act_id, const unit *target_unit)
Checks if there is any hopes that the action is possible against the target unit (by chacking the tar...
QString strvec_to_and_list(const QVector< QString > &psv)
const char * calendar_text()
Produce a statically allocated textual representation of the current calendar time.
const char * textyear(int year)
Produce a statically allocated textual representation of the given year.
#define citizens_foreign_iterate_end
#define citizens_foreign_iterate(_pcity, _pslot, _nationality)
struct output_type * get_output_type(Output_type_id output)
Return the output type for this index.
int city_production_build_shield_cost(const struct city *pcity)
Return the number of shields it takes to build current city production.
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city has this building in it.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
int player_base_citizen_happiness(const struct player *pplayer)
Give base happiness in any city owned by pplayer.
int city_airlift_max(const struct city *pcity)
A city's maximum airlift capacity.
bool city_is_occupied(const struct city *pcity)
Returns TRUE iff the city is occupied.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
int city_unit_unhappiness(const unit *punit, int *free_unhappy)
Query unhappiness caused by a given unit.
int city_tile_output(const struct city *pcity, const struct tile *ptile, bool is_celebrating, Output_type_id otype)
Calculate the output for the tile.
citizens city_size_get(const struct city *pcity)
Get the city size.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
bool client_has_player()
Either controlling or observing.
bool client_is_global_observer()
Returns whether client is global observer.
struct player * client_player()
Either controlling or observing.
QString concat_tile_activity_text(struct tile *ptile)
Creates the activity progress text for the given tile.
enum known_type client_tile_get_known(const struct tile *ptile)
A tile's "known" field is used by the server to store whether each player knows the tile.
void nuclear_winter_scaled(int *chance, int *rate, int max)
Return nuclear winter chance and rate of change, scaled to max.
void global_warming_scaled(int *chance, int *rate, int max)
Return global warming chance and rate of change, scaled to max.
struct city * get_nearest_city(const struct unit *punit, int *sq_dist)
Find city nearest to given unit and optionally return squared city distance Parameter sq_dist may be ...
double unit_win_chance(const struct unit *attacker, const struct unit *defender)
Returns a double in the range [0;1] indicating the attackers chance of winning.
std::vector< unit * > & get_units_in_focus()
Returns list of units currently in focus.
unit * find_visible_unit(const ::tile *ptile)
Return a pointer to a visible unit, if there is one.
int city_history_gain(const struct city *pcity)
How much history city gains this turn.
int nation_history_gain(const struct player *pplayer)
How much nation-wide history player gains this turn.
struct effect_list * effects[EFT_COUNT]
int get_player_output_bonus(const struct player *pplayer, const struct output_type *poutput, enum effect_type effect_type)
Returns the player effect bonus of an output.
int get_city_bonus_effects(struct effect_list *plist, const struct city *pcity, const struct output_type *poutput, enum effect_type effect_type)
Returns the effect sources of this type currently active at the city.
QString effect_type_unit_text(effect_type type, int value)
Returns a string describing an effect value as interpreted in the context of an effect_type,...
void get_effect_req_text(const struct effect *peffect, char *buf, size_t buf_len)
Make user-friendly text for the source.
const effect_list * get_effects()
Get a list of all effects.
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
#define effect_list_iterate_end
#define effect_list_iterate(effect_list, peffect)
enum output_type_id Output_type_id
#define PL_(String1, String2, n)
const char * population_to_text(int thousand_citizen)
Return a prettily formatted string containing the population text.
int civ_population(const struct player *pplayer)
Count the # of thousand citizen in a civilisation.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
bool can_unit_move_now(const struct unit *punit)
Returns if unit can move now.
const char * government_name_for_player(const struct player *pplayer)
Return the (translated) name of the given government of a player.
Impr_type_id improvement_count()
Return the number of improvements.
bool is_improvement_visible(const struct impr_type *pimprove)
Return TRUE if the improvement should be visible to others without spying.
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define index_to_native_pos(pnat_x, pnat_y, mindex)
#define index_to_map_pos(pmap_x, pmap_y, mindex)
const char * move_points_text_full(int mp, bool reduce, const char *prefix, const char *none, bool align)
Render positive movement points as text, including fractional movement points, scaled by SINGLE_MOVE.
int unit_move_rate(const struct unit *punit)
This function calculates the move rate of the unit.
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
struct city_list * cities
struct player * player_by_number(const int player_id)
Return struct player pointer for the given player index.
int player_get_expected_income(const struct player *pplayer)
Return the expected net income of the player this turn.
int player_count()
Return the number of players.
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players can attack each other.
struct city * player_city_by_number(const struct player *pplayer, int city_id)
If the specified player owns the city with the specified id, return pointer to the city struct.
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the player can see units in the city.
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Returns the number of technologies the player need to research to get the goal technology.
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
Returns if the given tech has to be researched to reach the goal.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
QString research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Store the translated name of the given tech (including A_FUTURE) in 'buf'.
int research_goal_bulbs_required(const struct research *presearch, Tech_type_id goal)
Function to determine cost (in bulbs) of reaching goal technology.
#define research_players_iterate(_presearch, _pplayer)
#define research_players_iterate_end
void format_time_duration(time_t t, char *buf, int maxlen)
Convenience function to nicely format a time_t seconds value in to a string with hours,...
#define CLIP(lower, current, upper)
citizens feel[CITIZEN_LAST][FEELING_LAST]
struct unit_list * units_supported
struct packet_game_info info
enum spaceship_state state
struct city_list * cities
struct player::@65::@68 client
char username[MAX_LEN_NAME]
struct player_economic economic
struct player_score score
struct nation_type * nation
struct research::@71::@73 client
struct goods_type * carrying
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
size_t fc_strlcpy(char *dest, const char *src, size_t n)
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-...
struct team * team_by_number(const int team_id)
Return struct team pointer for the given team index.
const char * team_name_translation(const struct team *pteam)
Returns the name (translated) of the team.
int team_count()
Return the current number of teams.
struct advance * valid_advance_by_number(const Tech_type_id id)
Returns pointer when the advance "exists" in this game, returns nullptr otherwise.
const char * get_infrastructure_text(bv_extras extras)
Return a (static) string with extra(s) name(s): eg: "Mine" eg: "Road/Farmland" This only includes "in...
QString text_happiness_wonders(const struct city *pcity)
Describing wonders that affect happiness.
QString get_score_text(const struct player *pplayer)
Return text giving the score of the player.
static void get_full_username(char *buf, int buflen, const struct player *pplayer)
For AIs, fill the buffer with their player name prefixed with "AI".
const QString get_nearest_city_text(struct city *pcity, int sq_dist)
Returns the text describing the city and its distance.
const QString science_dialog_text()
Returns the text to display in the science dialog.
const QString get_act_sel_action_custom_text(struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
Returns custom part of the action selection dialog button text for the specified action (given that t...
#define FAR_CITY_SQUARE_DIST
const QString get_science_target_text()
Get the short science-target text.
const QString unit_description(const unit *punit)
Returns the unit description.
int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs)
Return total expected bulbs.
const QString act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Get information about starting the action in the current situation.
QString text_happiness_luxuries(const struct city *pcity)
Describing luxuries that affect happiness.
const QString popup_info_text(struct tile *ptile)
Text to popup on a middle-click in the mapview.
QString text_happiness_cities(const struct city *pcity)
Describing city factors that affect happiness.
QString text_happiness_buildings(const struct city *pcity)
Describe buildings that affect happiness (or rather, anything with a Make_Content effect).
bool get_units_upgrade_info(char *buf, size_t bufsz, const std::vector< unit * > &punits)
Return text about upgrading these unit lists.
static int turns_to_tech_loss(const struct research *presearch, int per_turn)
Return turns until an advance is lost due to tech upkeep.
const QString get_spaceship_descr(struct player_spaceship *pship)
Returns a description of the given spaceship.
const QString get_info_label_text_popup()
Return the text for the popup label on the info panel.
const QString get_tile_output_text(const struct tile *ptile)
Return a (static) string with a tile's food/prod/trade.
QString text_happiness_nationality(const struct city *pcity)
Describing nationality effects that affect happiness.
int turns_to_research_done(const struct research *presearch, int per_turn)
Return turns until research complete.
const QString get_info_label_text(bool moreinfo)
Return the text for the label on the info panel.
static void get_full_nation(char *buf, int buflen, const struct player *pplayer)
Fill the buffer with the player's nation name (in adjective form) and optionally add the player's tea...
const QString get_science_goal_text(Tech_type_id goal)
Set the science-goal-label text as if we're researching the given goal.
QString text_happiness_units(const struct city *pcity)
Describe units that affect happiness.
const QString get_airlift_text(const std::vector< unit * > &units, const struct city *pdest)
Describe the airlift capacity of a city for the given units (from their current positions).
static int turns_per_advance(const struct research *presearch, int per_turn)
Return turns per advance (based on currently researched advance).
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
Return a (static) string with tile name describing terrain and extras of some categories.
bool tile_has_visible_extra(const struct tile *ptile, const struct extra_type *pextra)
Returns TRUE if the given tile has a road of given type on it.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_continent(_tile)
#define tile_owner(_tile)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
Return TRUE iff the two cities are capable of trade; i.e., if a caravan from one city can enter the o...
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
Return the trade that exists between these cities, assuming they have a trade route.
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, const player *seen_as, struct goods_type *pgood, const bool establish_trade)
Returns the revenue trade bonus - you get this when establishing a trade route and also when you simp...
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
Returns TRUE iff the two cities can establish a trade route.
enum unit_upgrade_result unit_upgrade_test(const struct unit *punit, bool is_free)
Tests if the unit could be updated.
void unit_upkeep_astr(const struct unit *punit, QString &s)
Append a line of text describing the unit's upkeep to the astring.
bool is_military_unit(const struct unit *punit)
Military units are capable of enforcing martial law.
int unit_bribe_cost(struct unit *punit, struct player *briber)
Calculate how expensive it is to bribe the unit.
enum unit_upgrade_result unit_upgrade_info(const struct unit *punit, char *buf, size_t bufsz)
Find the result of trying to upgrade the unit, and a message that most callers can use directly.
enum unit_airlift_result test_unit_can_airlift_to(const struct player *restriction, const struct unit *punit, const struct city *pdest_city)
Determines if punit can be airlifted to dest_city now! So punit needs to be in a city now.
void unit_activity_astr(const struct unit *punit, QString &s)
Append text describing the unit's current activity to the given astring.
struct player * unit_nationality(const struct unit *punit)
Return the nationality of the unit.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Return whether this player can upgrade this unit type (to any other unit type).
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Return translated name of the given veteran level.
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Return the cost (gold) of upgrading a single unit of the specified type to the new type.