diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/clu/AmzuSwarmsHungerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/clu/AmzuSwarmsHungerTest.java index 381d815ed93e..f95eb4bef28e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/clu/AmzuSwarmsHungerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/clu/AmzuSwarmsHungerTest.java @@ -56,6 +56,7 @@ public void testGraveyardExile() { addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); addCard(Zone.GRAVEYARD, playerA, "Living Hive"); addCard(Zone.GRAVEYARD, playerA, "Saber Ants"); + addCard(Zone.GRAVEYARD, playerA, "Blasphemous Act"); // test non-permanent card type addCard(Zone.HAND, playerA, "Rakdos Charm"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Rakdos Charm", true); @@ -68,6 +69,6 @@ public void testGraveyardExile() { execute(); assertPermanentCount(playerA, "Insect Token", 1); - assertCounterCount(playerA, "Insect Token", CounterType.P1P1, 8); + assertCounterCount(playerA, "Insect Token", CounterType.P1P1, 9); } } diff --git a/Mage/src/main/java/mage/abilities/common/CardsLeaveGraveyardTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/CardsLeaveGraveyardTriggeredAbility.java index 93f6d13a534c..c88e5da5d948 100644 --- a/Mage/src/main/java/mage/abilities/common/CardsLeaveGraveyardTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/CardsLeaveGraveyardTriggeredAbility.java @@ -8,7 +8,7 @@ import mage.filter.StaticFilters; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeGroupEvent; +import mage.game.events.ZoneChangeBatchEvent; import java.util.Objects; import java.util.Set; @@ -38,19 +38,23 @@ private CardsLeaveGraveyardTriggeredAbility(final CardsLeaveGraveyardTriggeredAb @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ZONE_CHANGE_GROUP; + return event.getType() == GameEvent.EventType.ZONE_CHANGE_BATCH; } @Override public boolean checkTrigger(GameEvent event, Game game) { - ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; - if (zEvent == null || Zone.GRAVEYARD != zEvent.getFromZone() - || Zone.GRAVEYARD == zEvent.getToZone() || zEvent.getCards() == null){ + ZoneChangeBatchEvent zEvent = (ZoneChangeBatchEvent) event; + if (zEvent == null){ return false; } - Set cards = zEvent.getCards() + Set cards = zEvent.getEvents() .stream() .filter(Objects::nonNull) + .filter(ev -> ev.getFromZone() == Zone.GRAVEYARD) + .filter(ev -> ev.getToZone() != Zone.GRAVEYARD) + .map(GameEvent::getTargetId) + .map(game::getCard) + .filter(Objects::nonNull) .filter(card -> filter.match(card, getControllerId(), this, game)) .filter(card -> this.isControlledBy(card.getOwnerId())) .collect(Collectors.toSet()); diff --git a/Mage/src/main/java/mage/game/ZonesHandler.java b/Mage/src/main/java/mage/game/ZonesHandler.java index c4f428eeb57c..a719cdbedae2 100644 --- a/Mage/src/main/java/mage/game/ZonesHandler.java +++ b/Mage/src/main/java/mage/game/ZonesHandler.java @@ -7,6 +7,7 @@ import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.command.Commander; +import mage.game.events.ZoneChangeBatchEvent; import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeGroupEvent; import mage.game.permanent.Permanent; @@ -27,6 +28,7 @@ public final class ZonesHandler { public static boolean cast(ZoneChangeInfo info, Ability source, Game game) { if (maybeRemoveFromSourceZone(info, game, source)) { placeInDestinationZone(info, 0, source, game); + // create a group zone change event if a card is moved to stack for casting (it's always only one card, but some effects check for group events (one or more xxx)) Set cards = new HashSet<>(); Set tokens = new HashSet<>(); @@ -44,6 +46,12 @@ public static boolean cast(ZoneChangeInfo info, Ability source, Game game) { info.event.getPlayerId(), info.event.getFromZone(), info.event.getToZone())); + + // Fire batch event for cards moving to stack as well + ZoneChangeBatchEvent batchEvent = new ZoneChangeBatchEvent(); + batchEvent.addEvent(info.event); + game.fireEvent(batchEvent); + // normal movement game.fireEvent(info.event); return true;