mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -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) {
|
if (cost > 0) {
|
||||||
val stats = mutableListOf("$cost${Fonts.production}")
|
val stats = mutableListOf("$cost${Fonts.production}")
|
||||||
if (canBePurchasedWithStat(null, Stat.Gold)) {
|
if (canBePurchasedWithStat(null, Stat.Gold)) {
|
||||||
// We need what INonPerpetualConstruction.getBaseGoldCost calculates but without any game- or civ-specific modifiers
|
stats += "${getCivilopediaGoldCost()}${Fonts.gold}"
|
||||||
val buyCost = (30.0 * cost.toFloat().pow(0.75f) * hurryCostModifier.toPercent()).toInt() / 10 * 10
|
|
||||||
stats += "$buyCost${Fonts.gold}"
|
|
||||||
}
|
}
|
||||||
textList += FormattedLine(stats.joinToString(", ", "{Cost}: "))
|
textList += FormattedLine(stats.joinToString("/", "{Cost}: "))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiredTech != null)
|
if (requiredTech != null)
|
||||||
|
@ -63,6 +63,11 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
|
|||||||
return Stat.values().any { canBePurchasedWithStat(city, it) }
|
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 {
|
fun getBaseGoldCost(civInfo: Civilization): Double {
|
||||||
// https://forums.civfanatics.com/threads/rush-buying-formula.393892/
|
// https://forums.civfanatics.com/threads/rush-buying-formula.393892/
|
||||||
return (30.0 * getProductionCost(civInfo)).pow(0.75) * hurryCostModifier.toPercent()
|
return (30.0 * getProductionCost(civInfo)).pow(0.75) * hurryCostModifier.toPercent()
|
||||||
|
@ -93,9 +93,7 @@ object BaseUnitDescriptions {
|
|||||||
stats.clear()
|
stats.clear()
|
||||||
stats += "${baseUnit.cost}${Fonts.production}"
|
stats += "${baseUnit.cost}${Fonts.production}"
|
||||||
if (baseUnit.canBePurchasedWithStat(null, Stat.Gold)) {
|
if (baseUnit.canBePurchasedWithStat(null, Stat.Gold)) {
|
||||||
// We need what INonPerpetualConstruction.getBaseGoldCost calculates but without any game- or civ-specific modifiers
|
stats += "${baseUnit.getCivilopediaGoldCost()}${Fonts.gold}"
|
||||||
val buyCost = (30.0 * baseUnit.cost.toFloat().pow(0.75f) * baseUnit.hurryCostModifier.toPercent()).toInt() / 10 * 10
|
|
||||||
stats += "$buyCost${Fonts.gold}"
|
|
||||||
}
|
}
|
||||||
textList += FormattedLine(stats.joinToString("/", "{Cost}: "))
|
textList += FormattedLine(stats.joinToString("/", "{Cost}: "))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user