Resolved #581 - Turns to production values are now always accurate and don't depend on bonuses to the current production

This commit is contained in:
Yair Morgenstern 2019-03-25 19:52:29 +02:00
parent e43c22a74b
commit 3295753d2d

View File

@ -111,9 +111,19 @@ class CityConstructions {
fun turnsToConstruction(constructionName: String): Int { fun turnsToConstruction(constructionName: String): Int {
val workLeft = getRemainingWork(constructionName) val workLeft = getRemainingWork(constructionName)
val cityStats = cityInfo.cityStats.currentCityStats // The ol' Switcharoo - what would our stats be if that was our current construction?
var production = Math.round(cityStats.production) // Since this is only ever used for UI purposes, I feel fine with having it be a bit inefficient
if (constructionName == Settler) production += cityStats.food.toInt() // 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() return Math.ceil((workLeft / production.toDouble())).toInt()
} }