Resolved #3254 - food-to-production not added twice when calculating turns to production

This commit is contained in:
Yair Morgenstern 2020-10-11 22:10:32 +03:00
parent fa41076cf2
commit 9a887e4840
3 changed files with 5 additions and 4 deletions

View File

@ -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()
}

View File

@ -449,7 +449,7 @@ class CityStats {
cityInfo.civInfo.updateStatsForNextTurn()
}
private fun updateFinalStatList(){
private fun updateFinalStatList() {
val newFinalStatList = LinkedHashMap<String, Stats>() // 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

View File

@ -259,6 +259,8 @@ object RulesetCache :HashMap<String,Ruleset>() {
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!")
}