Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand the city dialog text for luxury spendings #1208

Merged
merged 1 commit into from
Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 67 additions & 5 deletions client/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1692,11 +1692,73 @@ const QString text_happiness_units(const struct city *pcity)
}

/**
Describing luxuries that affect happiness.
* Describing luxuries that affect happiness.
*/
const QString text_happiness_luxuries(const struct city *pcity)
QString text_happiness_luxuries(const struct city *pcity)
{
return QString(_("Luxury: %1 total."))
jwrober marked this conversation as resolved.
Show resolved Hide resolved
.arg(QString::number(pcity->prod[O_LUXURY]))
+ qendl();
auto str = QStringLiteral("<p>");

// Explain the rules
str += QString(_("For each %1 luxury good produced in a city, a citizen "
"becomes happier."))
.arg(game.info.happy_cost);
str += QStringLiteral(" ");

// Give the basis for calculation. Shortcut the rest if there's not enough
// to help a single citizen.
auto luxuries = pcity->prod[O_LUXURY];
if (luxuries == 0) {
str += _("This city generates no luxury goods.");
return str + QStringLiteral("</p>");
} else if (luxuries < game.info.happy_cost) {
str += QString(PL_("This city generates a total of %1 luxury good, not "
"enough to have an effect.",
"This city generates a total of %1 luxury goods, not "
"enough to have an effect.",
luxuries))
.arg(luxuries);
return str + QStringLiteral("</p>");
}

str += QString(PL_("This city generates a total of %1 luxury good.",
"This city generates a total of %1 luxury goods.",
luxuries))
.arg(luxuries);

str += QStringLiteral("</p><p>");

auto made_happy = pcity->feel[CITIZEN_HAPPY][FEELING_LUXURY]
- pcity->feel[CITIZEN_HAPPY][FEELING_BASE];
auto made_content = pcity->feel[CITIZEN_CONTENT][FEELING_LUXURY]
- pcity->feel[CITIZEN_CONTENT][FEELING_BASE];
auto made_unhappy = pcity->feel[CITIZEN_UNHAPPY][FEELING_LUXURY]
- pcity->feel[CITIZEN_UNHAPPY][FEELING_BASE];
int citizens_affected = std::max(0, made_happy) + std::max(0, made_content)
+ std::max(0, made_unhappy);
int upgrades = made_happy * 3 + made_content * 2 + made_unhappy * 1;
int cost = upgrades * game.info.happy_cost;

if (cost < luxuries) {
str +=
QString(PL_("%1 citizen is made happier using %2 luxury good(s).",
"%1 citizens are made happier using %2 luxury good(s).",
citizens_affected))
.arg(citizens_affected)
.arg(cost);
if (luxuries - cost > 0) {
str += QStringLiteral(" ");
str += QString(PL_("%1 luxury good is not used.",
"%1 luxury goods are not used.", luxuries - cost))
.arg(luxuries - cost);
}
} else {
str += QString(PL_("All available luxury goods are used to make %1 "
"citizen happier.",
"All available luxury goods are used to make %1 "
"citizens happier.",
citizens_affected))
.arg(citizens_affected);
}

return str + QStringLiteral("</p>");
}
2 changes: 1 addition & 1 deletion client/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const QString act_sel_action_tool_tip(const struct action *paction,
QString text_happiness_buildings(const struct city *pcity);
const QString text_happiness_nationality(const struct city *pcity);
QString text_happiness_cities(const struct city *pcity);
const QString text_happiness_luxuries(const struct city *pcity);
QString text_happiness_luxuries(const struct city *pcity);
const QString text_happiness_units(const struct city *pcity);
QString text_happiness_wonders(const struct city *pcity);
int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs);