Displayed Great Person point requirements always take game speed into account

This commit is contained in:
Yair Morgenstern 2023-01-18 13:09:10 +02:00
parent 48bf588b48
commit 002dd951f6
4 changed files with 14 additions and 6 deletions

View File

@ -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())

View File

@ -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<String>()
@ -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

View File

@ -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()

View File

@ -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())