mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-02 04:14:15 +07:00
Added missing notification when a privateer is attacked by a unit and plunders goods as a result (#4341)
* Added missing notification when a privateer is attacked by a unit and plunders goods as a result * Added an extra function to do it instead
This commit is contained in:
parent
b8d79dc23d
commit
433204bd6f
@ -181,29 +181,28 @@ object Battle {
|
||||
damageToAttacker -= attacker.getHealth() // ... but from here on they are accurate
|
||||
damageToDefender -= defender.getHealth()
|
||||
|
||||
if (attacker is MapUnitCombatant) {
|
||||
for (unique in attacker.unit.getMatchingUniques("Earn []% of the damage done to [] units as []"))
|
||||
if (defender.matchesCategory(unique.params[1])) {
|
||||
plunderFromDamage(attacker, defender, damageToDefender)
|
||||
plunderFromDamage(defender, attacker, damageToAttacker)
|
||||
}
|
||||
|
||||
private fun plunderFromDamage(plunderingUnit: ICombatant, plunderedUnit: ICombatant, damageDealt: Int) {
|
||||
if (plunderingUnit is MapUnitCombatant) {
|
||||
for (unique in plunderingUnit.unit.getMatchingUniques("Earn []% of the damage done to [] units as []")) {
|
||||
if (plunderedUnit.matchesCategory(unique.params[1])) {
|
||||
val resourcesPlundered =
|
||||
(unique.params[0].toFloat() / 100f * damageToDefender).toInt()
|
||||
attacker.getCivInfo().addStat(Stat.valueOf(unique.params[2]), resourcesPlundered)
|
||||
attacker.getCivInfo()
|
||||
(unique.params[0].toFloat() / 100f * damageDealt).toInt()
|
||||
plunderingUnit.getCivInfo().addStat(Stat.valueOf(unique.params[2]), resourcesPlundered)
|
||||
plunderingUnit.getCivInfo()
|
||||
.addNotification(
|
||||
"Your [${attacker.getName()}] plundered [${resourcesPlundered}] [${unique.params[2]}] from [${defender.getName()}]",
|
||||
defender.getTile().position,
|
||||
"Your [${plunderingUnit.getName()}] plundered [${resourcesPlundered}] [${unique.params[2]}] from [${plunderedUnit.getName()}]",
|
||||
plunderedUnit.getTile().position,
|
||||
NotificationIcon.War
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defender is MapUnitCombatant) {
|
||||
for (unique in defender.unit.getMatchingUniques("Earn []% of the damage done to [] units as []"))
|
||||
if (attacker.matchesCategory(unique.params[1]))
|
||||
defender.getCivInfo().addStat(Stat.valueOf(unique.params[2]), (unique.params[0].toFloat() / 100f * damageToAttacker).toInt())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun postBattleNotifications(
|
||||
attacker: ICombatant,
|
||||
defender: ICombatant,
|
||||
|
Loading…
Reference in New Issue
Block a user