From 9a887e4840d1b8e458419b88683a039ac606cd2a Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 11 Oct 2020 22:10:32 +0300 Subject: [PATCH] Resolved #3254 - food-to-production not added twice when calculating turns to production --- core/src/com/unciv/logic/city/CityConstructions.kt | 3 +-- core/src/com/unciv/logic/city/CityStats.kt | 4 ++-- core/src/com/unciv/models/ruleset/Ruleset.kt | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index 3acc93134a..13eeacf504 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -216,8 +216,7 @@ class CityConstructions { cityInfo.cityStats.update() } - var production = cityStatsForConstruction.production.roundToInt() - if (constructionName == Constants.settler) production += cityStatsForConstruction.food.toInt() + val production = cityStatsForConstruction.production.roundToInt() return ceil(workLeft / production.toDouble()).toInt() } diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 1650bd7c34..b54812f975 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -449,7 +449,7 @@ class CityStats { cityInfo.civInfo.updateStatsForNextTurn() } - private fun updateFinalStatList(){ + private fun updateFinalStatList() { val newFinalStatList = LinkedHashMap() // again, we don't edit the existing currentCityStats directly, in order to avoid concurrency exceptions for (entry in baseStatList) @@ -507,7 +507,7 @@ class CityStats { totalFood = newFinalStatList.values.map { it.food }.sum() // recalculate because of previous change // Since growth bonuses are special, (applied afterwards) they will be displayed separately in the user interface as well. - if(totalFood>0) { + if (totalFood > 0) { val foodFromGrowthBonuses = getGrowthBonusFromPoliciesAndWonders() * totalFood newFinalStatList["Policies"]!!.food += foodFromGrowthBonuses totalFood = newFinalStatList.values.map { it.food }.sum() // recalculate again diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 2544fc206a..e3208e27d7 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -259,6 +259,8 @@ object RulesetCache :HashMap() { println("${unit.name} requires resource ${unit.requiredResource} which does not exist!") if (unit.upgradesTo != null && !modRuleset.units.containsKey(unit.upgradesTo!!)) println("${unit.name} upgrades to unit ${unit.upgradesTo} which does not exist!") + if (unit.upgradesTo == unit.name) + println("${unit.name} upgrades to itself!") if (unit.replaces != null && !modRuleset.units.containsKey(unit.replaces!!)) println("${unit.replaces} replaces ${unit.replaces} which does not exist!") }