Fix DestroyPlaneswalkerWhenDamagedTriggeredAbility (#12093)

This commit is contained in:
jimga150 2024-04-10 23:42:44 -04:00 committed by GitHub
parent 1eda4aaad4
commit 40b1dcc526
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 5 deletions

View file

@ -40,13 +40,17 @@ public class DestroyPlaneswalkerWhenDamagedTriggeredAbility extends TriggeredAbi
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = getSourcePermanentIfItStillExists(game);
if (permanent == null) {
Permanent sourcePermanent = getSourcePermanentIfItStillExists(game);
if (sourcePermanent == null) {
return false;
}
boolean applies = filter != null ?
permanent.isPlaneswalker(game) && filter.match(permanent, game) : event.getSourceId().equals(getSourceId());
if (applies) {
Permanent damagedPermanent = game.getPermanent(event.getTargetId());
if (damagedPermanent == null) {
return false;
}
boolean targetsPlaneswalker = damagedPermanent.isPlaneswalker(game);
boolean filterMatch = filter != null ? filter.match(sourcePermanent, game) : event.getSourceId().equals(getSourceId());
if (targetsPlaneswalker && filterMatch) {
Effect effect = new DestroyTargetEffect();
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
this.getEffects().clear();