From 75059a7859442ced210f68acb9817217b5e22ab6 Mon Sep 17 00:00:00 2001 From: Duan Tao Date: Wed, 17 Jul 2019 16:51:50 +0800 Subject: [PATCH] Better expansion and population growth turns message. --- core/src/com/unciv/ui/cityscreen/CityScreen.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index 8c640a62f9..7c0ca756c4 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -16,6 +16,7 @@ import com.unciv.ui.utils.* import com.unciv.ui.worldscreen.TileGroupMap import java.util.* import kotlin.math.ceil +import kotlin.math.floor import kotlin.math.round class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { @@ -116,8 +117,9 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { val turnsToExpansionString : String if (city.cityStats.currentCityStats.culture > 0) { - val turnsToExpansion = ceil((city.expansion.getCultureToNextTile() - city.expansion.cultureStored) + var turnsToExpansion = ceil((city.expansion.getCultureToNextTile() - city.expansion.cultureStored) / city.cityStats.currentCityStats.culture).toInt() + if (turnsToExpansion < 1) turnsToExpansion = 1 turnsToExpansionString = "[$turnsToExpansion] turns to expansion".tr() } else { turnsToExpansionString = "Stopped expansion".tr() @@ -127,11 +129,12 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { val turnsToPopString : String if (city.cityStats.currentCityStats.food > 0) { - val turnsToPopulation = ceil((city.population.getFoodToNextPopulation()-city.population.foodStored) + var turnsToPopulation = ceil((city.population.getFoodToNextPopulation()-city.population.foodStored) / city.cityStats.currentCityStats.food).toInt() + if (turnsToPopulation < 1) turnsToPopulation = 1 turnsToPopString = "[$turnsToPopulation] turns to new population".tr() } else if (city.cityStats.currentCityStats.food < 0) { - val turnsToStarvation = ceil(city.population.foodStored / -city.cityStats.currentCityStats.food).toInt() + val turnsToStarvation = floor(city.population.foodStored / -city.cityStats.currentCityStats.food).toInt() + 1 turnsToPopString = "[$turnsToStarvation] turns to lose population".tr() } else { turnsToPopString = "Stopped population growth".tr()