Moved the stat-to-counter conversion forward to the CityInfo level

This commit is contained in:
Yair Morgenstern 2021-07-23 14:00:22 +03:00
parent cbfd658480
commit e6bac1c5b5
4 changed files with 14 additions and 10 deletions

View File

@ -2,10 +2,12 @@ package com.unciv.logic.city
import com.badlogic.gdx.math.Vector2
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.GreatPersonManager
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
import com.unciv.logic.map.RoadStatus
import com.unciv.logic.map.TileInfo
import com.unciv.logic.map.TileMap
import com.unciv.models.Counter
import com.unciv.models.ruleset.Unique
import com.unciv.models.ruleset.tile.ResourceSupplyList
import com.unciv.models.ruleset.tile.ResourceType
@ -371,11 +373,11 @@ class CityInfo {
return stats
}
fun getGreatPersonPoints(): Stats {
fun getGreatPersonPoints(): Counter<String> {
val stats = Stats()
for (entry in getGreatPersonPointsForNextTurn().values)
stats.add(entry)
return stats
return GreatPersonManager.statsToGreatPersonCounter(stats)
}
internal fun getMaxHealth() = 200 + cityConstructions.getBuiltBuildings().sumBy { it.cityHealth }

View File

@ -14,6 +14,7 @@ import com.unciv.logic.map.MapUnit
import com.unciv.logic.map.TileInfo
import com.unciv.logic.trade.TradeEvaluation
import com.unciv.logic.trade.TradeRequest
import com.unciv.models.Counter
import com.unciv.models.metadata.GameSpeed
import com.unciv.models.ruleset.*
import com.unciv.models.ruleset.tile.ResourceSupplyList
@ -649,10 +650,10 @@ class CivilizationInfo {
}
}
fun getGreatPersonPointsForNextTurn(): Stats {
val stats = Stats()
for (city in cities) stats.add(city.getGreatPersonPoints())
return stats
fun getGreatPersonPointsForNextTurn(): Counter<String> {
val greatPersonPoints = Counter<String>()
for (city in cities) greatPersonPoints.add(city.getGreatPersonPoints())
return greatPersonPoints
}
fun canEnterTiles(otherCiv: CivilizationInfo): Boolean {
@ -692,7 +693,7 @@ class CivilizationInfo {
return placedUnit
}
/** Tries to place the a [unitName] unit into the [TileInfo] closest to the given the [position]
/** Tries to place the a [unitName] unit into the [TileInfo] closest to the given the [location]
* @param location where to try to place the unit
* @param unitName name of the [BaseUnit] to create and place
* @return created [MapUnit] or null if no suitable location was found

View File

@ -69,8 +69,8 @@ class GreatPersonManager {
return greatPerson
}
fun addGreatPersonPoints(greatPersonPointsForTurn: Stats) {
greatPersonPointsCounter.add(statsToGreatPersonCounter(greatPersonPointsForTurn))
fun addGreatPersonPoints(greatPersonPointsForTurn: Counter<String>) {
greatPersonPointsCounter.add(greatPersonPointsForTurn)
}

View File

@ -108,7 +108,8 @@ class StatsOverviewTable (
val greatPersonPoints = GreatPersonManager
.greatPersonCounterToStats(viewingPlayer.greatPeople.greatPersonPointsCounter)
.toHashMap()
val greatPersonPointsPerTurn = viewingPlayer.getGreatPersonPointsForNextTurn().toHashMap()
val greatPersonPointsPerTurn = GreatPersonManager
.greatPersonCounterToStats(viewingPlayer.getGreatPersonPointsForNextTurn()).toHashMap()
val pointsToGreatPerson = viewingPlayer.greatPeople.pointsForNextGreatPerson
greatPeopleTable.defaults().pad(5f)