Stats in citystatstable are always in the same order

turnsToGrowth and turnsToStarvation take into account food rounding on 'next turn'
This commit is contained in:
Yair Morgenstern
2020-03-25 13:36:14 +02:00
parent e0f14a582b
commit 4b3314fe7b
2 changed files with 5 additions and 5 deletions

View File

@ -148,7 +148,6 @@ class CityInfo {
if (amount > 0) {
cityResources.add(resource, amount, "Tiles")
}
}
for (building in cityConstructions.getBuiltBuildings().filter { it.requiredResource != null }) {
@ -215,8 +214,9 @@ class CityInfo {
/** Take null to mean infinity. */
fun getNumTurnsToNewPopulation(): Int? {
if (isGrowing()) {
var turnsToGrowth = ceil((population.getFoodToNextPopulation() - population.foodStored)
/ cityStats.currentCityStats.food).toInt()
val roundedFoodPerTurn = cityStats.currentCityStats.food.roundToInt().toFloat()
val remainingFood = population.getFoodToNextPopulation() - population.foodStored
var turnsToGrowth = ceil( remainingFood / roundedFoodPerTurn).toInt()
if (turnsToGrowth < 1) turnsToGrowth = 1
return turnsToGrowth
}
@ -227,7 +227,7 @@ class CityInfo {
/** Take null to mean infinity. */
fun getNumTurnsToStarvation(): Int? {
if (isStarving()) {
return floor(population.foodStored / -cityStats.currentCityStats.food).toInt() + 1
return population.foodStored / -cityStats.currentCityStats.food.roundToInt() + 1
}
return null

View File

@ -66,7 +66,7 @@ open class Stats() {
}
fun toHashMap(): HashMap<Stat, Float> {
return hashMapOf(Stat.Production to production,
return linkedMapOf(Stat.Production to production,
Stat.Culture to culture,
Stat.Gold to gold,
Stat.Food to food,