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.badlogic.gdx.math.Vector2
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.GreatPersonManager
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.RoadStatus
import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileInfo
import com.unciv.logic.map.TileMap import com.unciv.logic.map.TileMap
import com.unciv.models.Counter
import com.unciv.models.ruleset.Unique import com.unciv.models.ruleset.Unique
import com.unciv.models.ruleset.tile.ResourceSupplyList import com.unciv.models.ruleset.tile.ResourceSupplyList
import com.unciv.models.ruleset.tile.ResourceType import com.unciv.models.ruleset.tile.ResourceType
@ -371,11 +373,11 @@ class CityInfo {
return stats return stats
} }
fun getGreatPersonPoints(): Stats { fun getGreatPersonPoints(): Counter<String> {
val stats = Stats() val stats = Stats()
for (entry in getGreatPersonPointsForNextTurn().values) for (entry in getGreatPersonPointsForNextTurn().values)
stats.add(entry) stats.add(entry)
return stats return GreatPersonManager.statsToGreatPersonCounter(stats)
} }
internal fun getMaxHealth() = 200 + cityConstructions.getBuiltBuildings().sumBy { it.cityHealth } 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.map.TileInfo
import com.unciv.logic.trade.TradeEvaluation import com.unciv.logic.trade.TradeEvaluation
import com.unciv.logic.trade.TradeRequest import com.unciv.logic.trade.TradeRequest
import com.unciv.models.Counter
import com.unciv.models.metadata.GameSpeed import com.unciv.models.metadata.GameSpeed
import com.unciv.models.ruleset.* import com.unciv.models.ruleset.*
import com.unciv.models.ruleset.tile.ResourceSupplyList import com.unciv.models.ruleset.tile.ResourceSupplyList
@ -649,10 +650,10 @@ class CivilizationInfo {
} }
} }
fun getGreatPersonPointsForNextTurn(): Stats { fun getGreatPersonPointsForNextTurn(): Counter<String> {
val stats = Stats() val greatPersonPoints = Counter<String>()
for (city in cities) stats.add(city.getGreatPersonPoints()) for (city in cities) greatPersonPoints.add(city.getGreatPersonPoints())
return stats return greatPersonPoints
} }
fun canEnterTiles(otherCiv: CivilizationInfo): Boolean { fun canEnterTiles(otherCiv: CivilizationInfo): Boolean {
@ -692,7 +693,7 @@ class CivilizationInfo {
return placedUnit 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 location where to try to place the unit
* @param unitName name of the [BaseUnit] to create and place * @param unitName name of the [BaseUnit] to create and place
* @return created [MapUnit] or null if no suitable location was found * @return created [MapUnit] or null if no suitable location was found

View File

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

View File

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