mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 23:10:39 -04:00
Resolves #3800 in a more generic way
This commit is contained in:
parent
4d6b4cd957
commit
208ad1aa27
@ -99,8 +99,6 @@ object Battle {
|
|||||||
val unitCost = defeatedUnit.unit.baseUnit.cost
|
val unitCost = defeatedUnit.unit.baseUnit.cost
|
||||||
val bonusUniquePlaceholderText = "Earn []% of killed [] unit's [] as []"
|
val bonusUniquePlaceholderText = "Earn []% of killed [] unit's [] as []"
|
||||||
|
|
||||||
var goldReward = 0
|
|
||||||
var cultureReward = 0
|
|
||||||
val bonusUniques = ArrayList<Unique>()
|
val bonusUniques = ArrayList<Unique>()
|
||||||
|
|
||||||
bonusUniques.addAll(civUnit.getCivInfo().getMatchingUniques(bonusUniquePlaceholderText))
|
bonusUniques.addAll(civUnit.getCivInfo().getMatchingUniques(bonusUniquePlaceholderText))
|
||||||
@ -109,25 +107,22 @@ object Battle {
|
|||||||
bonusUniques.addAll(civUnit.unit.getMatchingUniques(bonusUniquePlaceholderText))
|
bonusUniques.addAll(civUnit.unit.getMatchingUniques(bonusUniquePlaceholderText))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (unique in bonusUniques) {
|
for (unique in bonusUniques) {
|
||||||
if (!defeatedUnit.matchesCategory(unique.params[1])) continue
|
if (!defeatedUnit.matchesCategory(unique.params[1])) continue
|
||||||
|
|
||||||
val yieldPercent = unique.params[0].toFloat() / 100
|
val yieldPercent = unique.params[0].toFloat() / 100
|
||||||
val defeatedUnitYieldSourceType = unique.params[2]
|
val defeatedUnitYieldSourceType = unique.params[2]
|
||||||
val yieldType = unique.params[3]
|
val yieldTypeSourceAmount =
|
||||||
val yieldTypeSourceAmount = if (defeatedUnitYieldSourceType == "Cost") unitCost else unitStr
|
if (defeatedUnitYieldSourceType == "Cost") unitCost else unitStr
|
||||||
val yieldAmount = (yieldTypeSourceAmount * yieldPercent).toInt()
|
val yieldAmount = (yieldTypeSourceAmount * yieldPercent).toInt()
|
||||||
|
|
||||||
|
try {
|
||||||
if (yieldType == "Gold")
|
val stat = Stat.valueOf(unique.params[3])
|
||||||
goldReward += yieldAmount
|
civUnit.getCivInfo().addStat(stat, yieldAmount)
|
||||||
else if (yieldType == "Culture")
|
} catch (ex: Exception) {
|
||||||
cultureReward += yieldAmount
|
} // parameter is not a stat
|
||||||
}
|
}
|
||||||
|
|
||||||
civUnit.getCivInfo().policies.addCulture(cultureReward)
|
|
||||||
civUnit.getCivInfo().addGold(goldReward)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun takeDamage(attacker: ICombatant, defender: ICombatant) {
|
private fun takeDamage(attacker: ICombatant, defender: ICombatant) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user