Fix civilopedia gold cost (#9729)

* Fix exponent being applied wrong

* Format more consistent with rest of project

* Fix building gold cost in civilopedia and use slash instead of a comma

* Add INonPerpetualConstruction.getCivilopediaGoldCost()
This commit is contained in:
Skekdog 2023-07-03 21:52:47 +01:00 committed by GitHub
parent afb30fb1ca
commit 8263d972ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -240,11 +240,9 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
if (cost > 0) {
val stats = mutableListOf("$cost${Fonts.production}")
if (canBePurchasedWithStat(null, Stat.Gold)) {
// We need what INonPerpetualConstruction.getBaseGoldCost calculates but without any game- or civ-specific modifiers
val buyCost = (30.0 * cost.toFloat().pow(0.75f) * hurryCostModifier.toPercent()).toInt() / 10 * 10
stats += "$buyCost${Fonts.gold}"
stats += "${getCivilopediaGoldCost()}${Fonts.gold}"
}
textList += FormattedLine(stats.joinToString(", ", "{Cost}: "))
textList += FormattedLine(stats.joinToString("/", "{Cost}: "))
}
if (requiredTech != null)

View File

@ -63,6 +63,11 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
return Stat.values().any { canBePurchasedWithStat(city, it) }
}
fun getCivilopediaGoldCost(): Int {
// Same as getBaseGoldCost, but without game-specific modifiers
return ((30.0 * cost.toFloat()).pow(0.75) * hurryCostModifier.toPercent() / 10).toInt() * 10
}
fun getBaseGoldCost(civInfo: Civilization): Double {
// https://forums.civfanatics.com/threads/rush-buying-formula.393892/
return (30.0 * getProductionCost(civInfo)).pow(0.75) * hurryCostModifier.toPercent()

View File

@ -93,9 +93,7 @@ object BaseUnitDescriptions {
stats.clear()
stats += "${baseUnit.cost}${Fonts.production}"
if (baseUnit.canBePurchasedWithStat(null, Stat.Gold)) {
// We need what INonPerpetualConstruction.getBaseGoldCost calculates but without any game- or civ-specific modifiers
val buyCost = (30.0 * baseUnit.cost.toFloat().pow(0.75f) * baseUnit.hurryCostModifier.toPercent()).toInt() / 10 * 10
stats += "$buyCost${Fonts.gold}"
stats += "${baseUnit.getCivilopediaGoldCost()}${Fonts.gold}"
}
textList += FormattedLine(stats.joinToString("/", "{Cost}: "))
}