From 3295753d2d76f4fd30f02abc48e72b36d29c01eb Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 25 Mar 2019 19:52:29 +0200 Subject: [PATCH] Resolved #581 - Turns to production values are now always accurate and don't depend on bonuses to the current production --- .../com/unciv/logic/city/CityConstructions.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index e5f1dc6a46..e01d133196 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -111,9 +111,19 @@ class CityConstructions { fun turnsToConstruction(constructionName: String): Int { val workLeft = getRemainingWork(constructionName) - val cityStats = cityInfo.cityStats.currentCityStats - var production = Math.round(cityStats.production) - if (constructionName == Settler) production += cityStats.food.toInt() + // The ol' Switcharoo - what would our stats be if that was our current construction? + // Since this is only ever used for UI purposes, I feel fine with having it be a bit inefficient + // and recalculating the entire city stats + val currConstruction = currentConstruction + currentConstruction = constructionName + cityInfo.cityStats.update() + val cityStatsForConstruction = cityInfo.cityStats.currentCityStats + // revert! + currentConstruction = currConstruction + cityInfo.cityStats.update() + + var production = Math.round(cityStatsForConstruction.production) + if (constructionName == Settler) production += cityStatsForConstruction.food.toInt() return Math.ceil((workLeft / production.toDouble())).toInt() }