From 4f802e813ab10a003683c551b449bbad484fb54d Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 27 Apr 2021 00:37:51 +0300 Subject: [PATCH] Added Happiness (and Faith for Religion mods) to stats list - #3524 --- .../com/unciv/ui/cityscreen/CityStatsTable.kt | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt index f08ff04423..f2f171aa82 100644 --- a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt @@ -31,10 +31,11 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { innerTable.clear() val ministatsTable = Table() - for (stat in cityInfo.cityStats.currentCityStats.toHashMap()) { - if (stat.key == Stat.Happiness || stat.key == Stat.Faith) continue - ministatsTable.add(ImageGetter.getStatIcon(stat.key.name)).size(20f).padRight(5f) - ministatsTable.add(round(stat.value).toInt().toString().toLabel()).padRight(10f) + for ((stat, amount) in cityInfo.cityStats.currentCityStats.toHashMap()) { + if (stat == Stat.Faith && !cityInfo.getRuleset().hasReligion()) continue + ministatsTable.add(ImageGetter.getStatIcon(stat.name)).size(20f).padRight(5f) + val valueToDisplay = if (stat == Stat.Happiness) cityInfo.cityStats.happinessList.values.sum() else amount + ministatsTable.add(round(valueToDisplay).toInt().toString().toLabel()).padRight(10f) } innerTable.add(ministatsTable) @@ -47,8 +48,8 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { } private fun addText() { - val unassignedPopString = "{Unassigned population}:".tr() + - " " + cityInfo.population.getFreePopulation().toString() + "/" + cityInfo.population.population + val unassignedPopString = "{Unassigned population}: ".tr() + + cityInfo.population.getFreePopulation().toString() + "/" + cityInfo.population.population var turnsToExpansionString = if (cityInfo.cityStats.currentCityStats.culture > 0 && cityInfo.expansion.chooseNewTileToOwn() != null) { @@ -56,23 +57,21 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { var turnsToExpansion = ceil(remainingCulture / cityInfo.cityStats.currentCityStats.culture).toInt() if (turnsToExpansion < 1) turnsToExpansion = 1 "[$turnsToExpansion] turns to expansion".tr() - } else { - "Stopped expansion".tr() - } + } else "Stopped expansion".tr() if (cityInfo.expansion.chooseNewTileToOwn() != null) - turnsToExpansionString += " (" + cityInfo.expansion.cultureStored + "/" + - cityInfo.expansion.getCultureToNextTile() + ")" + turnsToExpansionString += + " (${cityInfo.expansion.cultureStored}/${cityInfo.expansion.getCultureToNextTile()})" var turnsToPopString = when { - cityInfo.isGrowing() -> "[${cityInfo.getNumTurnsToNewPopulation()}] turns to new population".tr() - cityInfo.isStarving() -> "[${cityInfo.getNumTurnsToStarvation()}] turns to lose population".tr() + cityInfo.isGrowing() -> "[${cityInfo.getNumTurnsToNewPopulation()}] turns to new population" + cityInfo.isStarving() -> "[${cityInfo.getNumTurnsToStarvation()}] turns to lose population" cityInfo.getRuleset().units[cityInfo.cityConstructions.currentConstructionFromQueue] .let { it != null && it.uniques.contains("Excess Food converted to Production when under construction") } - -> "Food converts to production".tr() - else -> "Stopped population growth".tr() - } - turnsToPopString += " (" + cityInfo.population.foodStored + "/" + cityInfo.population.getFoodToNextPopulation() + ")" + -> "Food converts to production" + else -> "Stopped population growth" + }.tr() + turnsToPopString += " (${cityInfo.population.foodStored}/${cityInfo.population.getFoodToNextPopulation()})" innerTable.add(unassignedPopString.toLabel()).row() innerTable.add(turnsToExpansionString.toLabel()).row()