Fixed hurry cost modifiers, and unit gold costs scaling according to game speed

This commit is contained in:
Yair Morgenstern
2021-03-06 23:45:50 +02:00
parent 43be37a3b8
commit d15456baa8
4 changed files with 6 additions and 6 deletions

View File

@ -593,7 +593,7 @@ class MapUnit {
destroy()
if (currentTile.getOwner() == civInfo)
civInfo.gold += baseUnit.getDisbandGold()
civInfo.gold += baseUnit.getDisbandGold(civInfo)
if (civInfo.isDefeated()) civInfo.destroy()
}

View File

@ -240,7 +240,7 @@ class Building : NamedStats(), IConstruction {
override fun getGoldCost(civInfo: CivilizationInfo): Int {
// https://forums.civfanatics.com/threads/rush-buying-formula.393892/
var cost = (30 * getProductionCost(civInfo)).toDouble().pow(0.75) * (1 + hurryCostModifier / 100)
var cost = (30 * getProductionCost(civInfo)).toDouble().pow(0.75) * (1 + hurryCostModifier / 100f)
for (unique in civInfo.getMatchingUniques("Cost of purchasing items in cities reduced by []%"))
cost *= 1 - (unique.params[0].toFloat() / 100)

View File

@ -106,17 +106,17 @@ class BaseUnit : INamed, IConstruction {
return productionCost.toInt()
}
fun getBaseGoldCost() = (30.0 * cost).pow(0.75) * (1 + hurryCostModifier / 100)
fun getBaseGoldCost(civInfo: CivilizationInfo) = (30.0 * cost).pow(0.75) * (1 + hurryCostModifier / 100f) * civInfo.gameInfo.gameParameters.gameSpeed.modifier
override fun getGoldCost(civInfo: CivilizationInfo): Int {
var cost = getBaseGoldCost()
var cost = getBaseGoldCost(civInfo)
if (civInfo.hasUnique("Gold cost of purchasing units -33%")) cost *= 0.66f
for (unique in civInfo.getMatchingUniques("Cost of purchasing items in cities reduced by []%"))
cost *= 1 - (unique.params[0].toFloat() / 100)
return (cost / 10).toInt() * 10 // rounded down o nearest ten
}
fun getDisbandGold() = getBaseGoldCost().toInt() / 20
fun getDisbandGold(civInfo: CivilizationInfo) = getBaseGoldCost(civInfo).toInt() / 20
override fun shouldBeDisplayed(construction: CityConstructions): Boolean {
val rejectionReason = getRejectionReason(construction)

View File

@ -77,7 +77,7 @@ object UnitActions {
action = {
if (!worldScreen.hasOpenPopups()) {
val disbandText = if (unit.currentTile.getOwner() == unit.civInfo)
"Disband this unit for [${unit.baseUnit.getDisbandGold()}] gold?".tr()
"Disband this unit for [${unit.baseUnit.getDisbandGold(unit.civInfo)}] gold?".tr()
else "Do you really want to disband this unit?".tr()
YesNoPopup(disbandText, { unit.disband(); worldScreen.shouldUpdate = true }).open()
}