-
Notifications
You must be signed in to change notification settings - Fork 778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix addSimultaneousDamage to avoid adding damage events to existing DamagedBatchForOnePlayerEvent instances when they shouldn't #11943
Conversation
…amagedBatchForOnePlayerEvent instances when they shouldnt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find. Thanks for the investigation.
DamagedBatchForOnePlayerEvent oldPlayerBatch = (DamagedBatchForOnePlayerEvent) event; | ||
if (oldPlayerBatch.getDamageClazz().isInstance(damagedEvent) | ||
&& event.getPlayerId().equals(damagedEvent.getTargetId())) { | ||
oldPlayerBatch.addEvent(damagedEvent); | ||
isPlayerBatchUsed = true; | ||
} | ||
} else if ((event instanceof DamagedBatchEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we should add more comments here to clarify that this covers DamagedBatchForPermanentsEvent
and DamagedBatchForPlayersEvent
Existing test coverage from |
This is for the multiple permanent and player damage batches, which is good, but i wonder if there's a way to see that the fix this does actually works as well. |
It is possible to add custom abilities to cards in unit test framework if you want to try. I don't think it's really necessary, assuming that #11841 will include an analogous test for the one permanent batch event. |
I don't see how existing cards would be bugged - Changing the inheritance structure would also have solved this issue but I don't see why it's a better or worse solution. |
Bug discovered in #11841
Currently,
addSimultaneousDamage
checks to see if a givenGameEvent
insimultaneousEvents
is aDamagedBatchEvent
to add it to that batch, BEFORE doing the check to see if that batch event is actually aDamagedBatchForOnePlayerEvent
and the target matches. because if that condition isn't satisfied, theDamagedEvent
instance should NOT be added to that batch eventThis results in
DamagedEvent
instances being added toDamagedBatchForOnePlayerEvent
instances fired in the same timing window regardless of whether the targets match, possibly conglomerating more damage into theDamagedBatchForOnePlayerEvent
than it should have.This should fix that behavior.
I want to write a test to show this works, but i see no cards that would be affected by this bug. Most use "when combat damage to player happens, do <thing that doesn't care about how much damage it was>", and the ones that care about how much damage it was (Quartzwood Crasher, Anowon, the Ruin Thief, and Lolth, Spider Queen) still only care about combat damage, which wont let me test a scenario where different players are dealt damage by different targets at the same time.
Maybe there is no way that scenario could happen normally, but this behavior will be important for implementing
DamageBatchForOnePermanent
, where this happens all the time. Thoughts?