mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 05:14:32 -04:00
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:
parent
afb30fb1ca
commit
8263d972ff
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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}: "))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user