From f333886110d23d073fe392319958ac77fbdb5885 Mon Sep 17 00:00:00 2001 From: Jeff Wadsworth Date: Tue, 12 Dec 2023 15:19:54 -0600 Subject: [PATCH] Mogg Infestation now counts destroyed tokens as well. --- .../src/mage/cards/m/MoggInfestation.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Mage.Sets/src/mage/cards/m/MoggInfestation.java b/Mage.Sets/src/mage/cards/m/MoggInfestation.java index 7620b19dd27..9babf6aa34f 100644 --- a/Mage.Sets/src/mage/cards/m/MoggInfestation.java +++ b/Mage.Sets/src/mage/cards/m/MoggInfestation.java @@ -1,21 +1,21 @@ package mage.cards.m; +import java.util.HashSet; +import java.util.Set; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenTargetEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentToken; import mage.game.permanent.token.GoblinToken; import mage.players.Player; import mage.target.TargetPlayer; @@ -48,7 +48,7 @@ public final class MoggInfestation extends CardImpl { class MoggInfestationEffect extends OneShotEffect { public MoggInfestationEffect() { - super(Outcome.DestroyPermanent); + super(Outcome.Detriment); this.staticText = "Destroy all creatures target player controls. For each creature that died this way, create two 1/1 red Goblin creature tokens under that player's control"; } @@ -64,13 +64,15 @@ class MoggInfestationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Cards creaturesDied = new CardsImpl(); + Set creaturesDied = new HashSet<>(); // note, permanent and token creatures are counted if (controller != null && getTargetPointer().getFirst(game, source) != null) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) { if (permanent.destroy(source, game, false)) { - if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) { // If a commander is replaced to command zone, the creature does not die - creaturesDied.add(permanent); + if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD + || (permanent instanceof PermanentToken + && !game.getState().getBattlefield().containsPermanent(permanent.getId()))) { // If a commander is replaced to command zone, the creature does not die + creaturesDied.add(permanent.getId()); } } } @@ -78,8 +80,10 @@ class MoggInfestationEffect extends OneShotEffect { return true; } game.getState().processAction(game); // Bug #8548 - for (Card c : creaturesDied.getCards(game)) { - if (game.getState().getZone(c.getId()) == Zone.GRAVEYARD) { + for (UUID uuid : creaturesDied) { + if (game.getState().getZone(uuid) == Zone.GRAVEYARD + || (game.getLastKnownInformation(uuid, Zone.BATTLEFIELD) instanceof PermanentToken + && !game.getBattlefield().containsPermanent(uuid))) { Effect effect = new CreateTokenTargetEffect(new GoblinToken(), 2); effect.setTargetPointer(getTargetPointer()); effect.apply(game, source);