From 002dd951f6dc4af127db209d814800d91113550a Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 18 Jan 2023 13:09:10 +0200 Subject: [PATCH] Displayed Great Person point requirements always take game speed into account --- .../unciv/logic/civilization/CivilizationInfo.kt | 3 ++- .../unciv/logic/civilization/GreatPersonManager.kt | 13 ++++++++++--- core/src/com/unciv/ui/cityscreen/CityStatsTable.kt | 2 +- .../unciv/ui/overviewscreen/StatsOverviewTable.kt | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 9ddd5c9131..1febfefae7 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -847,6 +847,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization { fun setTransients() { goldenAges.civInfo = this + greatPeople.civInfo = this civConstructions.setTransients(civInfo = this) @@ -956,7 +957,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization { // Generate great people at the start of the turn, // so they won't be generated out in the open and vulnerable to enemy attacks before you can control them if (cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception - val greatPerson = greatPeople.getNewGreatPerson(gameInfo.speed.modifier) + val greatPerson = greatPeople.getNewGreatPerson() if (greatPerson != null && gameInfo.ruleSet.units.containsKey(greatPerson)) addUnit(greatPerson) religionManager.startTurn() if (isLongCountActive()) diff --git a/core/src/com/unciv/logic/civilization/GreatPersonManager.kt b/core/src/com/unciv/logic/civilization/GreatPersonManager.kt index f254cd9916..68b205a0d1 100644 --- a/core/src/com/unciv/logic/civilization/GreatPersonManager.kt +++ b/core/src/com/unciv/logic/civilization/GreatPersonManager.kt @@ -8,7 +8,12 @@ import com.unciv.models.Counter // todo: GP from Maya long count should increase threshold as well - implement together class GreatPersonManager : IsPartOfGameInfoSerialization { - var pointsForNextGreatPerson = 100 + + @Transient + lateinit var civInfo: CivilizationInfo + + /** Base points, without speed modifier */ + private var pointsForNextGreatPerson = 100 var pointsForNextGreatGeneral = 200 var greatPersonPointsCounter = Counter() @@ -31,7 +36,9 @@ class GreatPersonManager : IsPartOfGameInfoSerialization { return toReturn } - fun getNewGreatPerson(gameSpeedModifier:Float): String? { + fun getPointsRequiredForGreatPerson() = (pointsForNextGreatPerson * civInfo.gameInfo.speed.modifier).toInt() + + fun getNewGreatPerson(): String? { if (greatGeneralPoints > pointsForNextGreatGeneral) { greatGeneralPoints -= pointsForNextGreatGeneral pointsForNextGreatGeneral += 50 @@ -39,7 +46,7 @@ class GreatPersonManager : IsPartOfGameInfoSerialization { } for ((key, value) in greatPersonPointsCounter) { - val requiredPoints = (pointsForNextGreatPerson * gameSpeedModifier).toInt() + val requiredPoints = getPointsRequiredForGreatPerson() if (value >= requiredPoints) { greatPersonPointsCounter.add(key, -requiredPoints) pointsForNextGreatPerson *= 2 diff --git a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt index 21820d46d1..b4e23dfbe6 100644 --- a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt @@ -354,7 +354,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { info.add("{$greatPersonName} (+$gppPerTurn)".toLabel()).left().padBottom(4f).expandX().row() val gppCurrent = cityInfo.civInfo.greatPeople.greatPersonPointsCounter[greatPersonName] - val gppNeeded = cityInfo.civInfo.greatPeople.pointsForNextGreatPerson + val gppNeeded = cityInfo.civInfo.greatPeople.getPointsRequiredForGreatPerson() val percent = gppCurrent!! / gppNeeded.toFloat() diff --git a/core/src/com/unciv/ui/overviewscreen/StatsOverviewTable.kt b/core/src/com/unciv/ui/overviewscreen/StatsOverviewTable.kt index f816721d43..3560644e15 100644 --- a/core/src/com/unciv/ui/overviewscreen/StatsOverviewTable.kt +++ b/core/src/com/unciv/ui/overviewscreen/StatsOverviewTable.kt @@ -159,7 +159,7 @@ class StatsOverviewTab( val greatPersonPoints = viewingPlayer.greatPeople.greatPersonPointsCounter val greatPersonPointsPerTurn = viewingPlayer.getGreatPersonPointsForNextTurn() - val pointsToGreatPerson = viewingPlayer.greatPeople.pointsForNextGreatPerson + val pointsToGreatPerson = viewingPlayer.greatPeople.getPointsRequiredForGreatPerson() for ((greatPerson, points) in greatPersonPoints) { add(greatPerson.toLabel()).left() add("$points/$pointsToGreatPerson".toLabel())