mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Fix addSimultaneousDamage to avoid adding damage events to existing DamagedBatchForOnePlayerEvent instances when they shouldn't (#11943)
* Fix addSimultaneousDamage to avoid adding damage events to existing DamagedBatchForOnePlayerEvent instances when they shouldnt * Add clarifying comment
This commit is contained in:
parent
f639cdf8d1
commit
b29a4e6349
1 changed files with 11 additions and 8 deletions
|
|
@ -823,21 +823,24 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
boolean isPlayerBatchUsed = false;
|
||||
for (GameEvent event : simultaneousEvents) {
|
||||
|
||||
// per damage type
|
||||
if ((event instanceof DamagedBatchEvent)
|
||||
&& ((DamagedBatchEvent) event).getDamageClazz().isInstance(damagedEvent)) {
|
||||
((DamagedBatchEvent) event).addEvent(damagedEvent);
|
||||
isDamageBatchUsed = true;
|
||||
}
|
||||
|
||||
// per player
|
||||
if (isPlayerDamage && event instanceof DamagedBatchForOnePlayerEvent) {
|
||||
// per player
|
||||
DamagedBatchForOnePlayerEvent oldPlayerBatch = (DamagedBatchForOnePlayerEvent) event;
|
||||
if (oldPlayerBatch.getDamageClazz().isInstance(damagedEvent)
|
||||
&& event.getPlayerId().equals(damagedEvent.getTargetId())) {
|
||||
oldPlayerBatch.addEvent(damagedEvent);
|
||||
isPlayerBatchUsed = true;
|
||||
}
|
||||
} else if ((event instanceof DamagedBatchEvent)
|
||||
&& ((DamagedBatchEvent) event).getDamageClazz().isInstance(damagedEvent)) {
|
||||
// per damage type
|
||||
// If the batch event isn't DAMAGED_BATCH_FOR_ONE_PLAYER, the targetIDs need not match,
|
||||
// since "event" is a generic batch in this case
|
||||
// (either DAMAGED_BATCH_FOR_PERMANENTS or DAMAGED_BATCH_FOR_PLAYERS)
|
||||
// Just needs to be a permanent-damaging event for DAMAGED_BATCH_FOR_PERMANENTS,
|
||||
// or a player-damaging event for DAMAGED_BATCH_FOR_PLAYERS
|
||||
((DamagedBatchEvent) event).addEvent(damagedEvent);
|
||||
isDamageBatchUsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue