From 0a62d96238727244dc8ea4ddf81476b98af1b599 Mon Sep 17 00:00:00 2001 From: Alex Vasile <48962821+Alex-Vasile@users.noreply.github.com> Date: Fri, 9 Sep 2022 22:54:11 -0400 Subject: [PATCH] [USG] Planar Void no longer triggers on tokens entering the graveyard. Closes #9071. --- Mage.Sets/src/mage/cards/p/PlanarVoid.java | 55 ++++--------------- .../test/cards/single/usg/PlanarVoidTest.java | 52 ++++++++++++++++++ 2 files changed, 63 insertions(+), 44 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/usg/PlanarVoidTest.java diff --git a/Mage.Sets/src/mage/cards/p/PlanarVoid.java b/Mage.Sets/src/mage/cards/p/PlanarVoid.java index 5a3abafa9f..854f0ed621 100644 --- a/Mage.Sets/src/mage/cards/p/PlanarVoid.java +++ b/Mage.Sets/src/mage/cards/p/PlanarVoid.java @@ -1,15 +1,14 @@ package mage.cards.p; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.effects.common.ExileTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; -import mage.target.targetpointer.FixedTarget; +import mage.constants.SetTargetPointer; +import mage.constants.TargetController; +import mage.filter.FilterCard; +import mage.filter.predicate.mageobject.AnotherPredicate; import java.util.UUID; @@ -18,11 +17,16 @@ import java.util.UUID; */ public final class PlanarVoid extends CardImpl { + private static final FilterCard filter = new FilterCard(); + static { + filter.add(AnotherPredicate.instance); + } + public PlanarVoid(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{B}"); // Whenever another card is put into a graveyard from anywhere, exile that card. - this.addAbility(new PlanarVoidTriggeredAbility()); + this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility(new ExileTargetEffect(), false, filter, TargetController.ANY, SetTargetPointer.CARD)); } private PlanarVoid(final PlanarVoid card) { @@ -34,40 +38,3 @@ public final class PlanarVoid extends CardImpl { return new PlanarVoid(this); } } - -class PlanarVoidTriggeredAbility extends TriggeredAbilityImpl { - - PlanarVoidTriggeredAbility() { - super(Zone.BATTLEFIELD, new ExileTargetEffect(), false); - } - - private PlanarVoidTriggeredAbility(final PlanarVoidTriggeredAbility ability) { - super(ability); - } - - @Override - public PlanarVoidTriggeredAbility copy() { - return new PlanarVoidTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ZONE_CHANGE; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - ZoneChangeEvent zEvent = (ZoneChangeEvent) event; - if (zEvent.getToZone() != Zone.GRAVEYARD - || event.getTargetId().equals(getSourceId())) { - return false; - } - this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game)); - return true; - } - - @Override - public String getRule() { - return "Whenever another card is put into a graveyard from anywhere, exile that card."; - } -} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/usg/PlanarVoidTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/usg/PlanarVoidTest.java new file mode 100644 index 0000000000..29b439f780 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/usg/PlanarVoidTest.java @@ -0,0 +1,52 @@ +package org.mage.test.cards.single.usg; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * {@link mage.cards.p.PlanarVoid Planar Void} + * {B} + * Enchantment + * Whenever another card is put into a graveyard from anywhere, exile that card. + * + * @author Alex-Vasile + */ +public class PlanarVoidTest extends CardTestPlayerBase { + private static final String planarVoid = "Planar Void"; + + /** + * Test that it triggers for another card going to the graveyard. + */ + @Test + public void triggersForOthers() { + addCard(Zone.BATTLEFIELD, playerA, planarVoid); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain"); + addCard(Zone.HAND, playerA, "Lightning Bolt"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Silvercoat Lion"); + + setStopAt(1, PhaseStep.PRECOMBAT_MAIN); + execute(); + assertExileCount(playerA, "Lightning Bolt", 1); + assertExileCount(playerA, "Silvercoat Lion", 1); + } + + /** + * Test that it doesn't trigger for itself + */ + @Test + public void doesntTriggerForItself() { + addCard(Zone.BATTLEFIELD, playerA, planarVoid); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); + addCard(Zone.HAND, playerA, "Allay"); // {1}{W} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Allay"); + + setStopAt(1, PhaseStep.PRECOMBAT_MAIN); + execute(); + assertGraveyardCount(playerA, planarVoid, 1); + } +}