mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04: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
|
damageToAttacker -= attacker.getHealth() // ... but from here on they are accurate
|
||||||
damageToDefender -= defender.getHealth()
|
damageToDefender -= defender.getHealth()
|
||||||
|
|
||||||
if (attacker is MapUnitCombatant) {
|
plunderFromDamage(attacker, defender, damageToDefender)
|
||||||
for (unique in attacker.unit.getMatchingUniques("Earn []% of the damage done to [] units as []"))
|
plunderFromDamage(defender, attacker, damageToAttacker)
|
||||||
if (defender.matchesCategory(unique.params[1])) {
|
}
|
||||||
|
|
||||||
|
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 =
|
val resourcesPlundered =
|
||||||
(unique.params[0].toFloat() / 100f * damageToDefender).toInt()
|
(unique.params[0].toFloat() / 100f * damageDealt).toInt()
|
||||||
attacker.getCivInfo().addStat(Stat.valueOf(unique.params[2]), resourcesPlundered)
|
plunderingUnit.getCivInfo().addStat(Stat.valueOf(unique.params[2]), resourcesPlundered)
|
||||||
attacker.getCivInfo()
|
plunderingUnit.getCivInfo()
|
||||||
.addNotification(
|
.addNotification(
|
||||||
"Your [${attacker.getName()}] plundered [${resourcesPlundered}] [${unique.params[2]}] from [${defender.getName()}]",
|
"Your [${plunderingUnit.getName()}] plundered [${resourcesPlundered}] [${unique.params[2]}] from [${plunderedUnit.getName()}]",
|
||||||
defender.getTile().position,
|
plunderedUnit.getTile().position,
|
||||||
NotificationIcon.War
|
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(
|
private fun postBattleNotifications(
|
||||||
attacker: ICombatant,
|
attacker: ICombatant,
|
||||||
defender: ICombatant,
|
defender: ICombatant,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user