diff --git a/Mage.Sets/src/mage/sets/commander2014/ContainmentPriest.java b/Mage.Sets/src/mage/sets/commander2014/ContainmentPriest.java index 12728e17d9..e9038af73c 100644 --- a/Mage.Sets/src/mage/sets/commander2014/ContainmentPriest.java +++ b/Mage.Sets/src/mage/sets/commander2014/ContainmentPriest.java @@ -33,6 +33,7 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.keyword.FlashAbility; +import mage.abilities.keyword.TransformAbility; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; @@ -122,6 +123,10 @@ class ContainmentPriestReplacementEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD) { Card card = game.getCard(event.getTargetId()); + Object entersTransformed = game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + event.getTargetId()); + if (entersTransformed instanceof Boolean && (Boolean) entersTransformed && card.getSecondCardFace() != null) { + card = card.getSecondCardFace(); + } if (card.getCardType().contains(CardType.CREATURE)) { // TODO: Bestow Card cast as Enchantment probably not handled correctly CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatchers().get("CreatureWasCast"); if (watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId())) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/planeswalker/JaceTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/planeswalker/JaceTest.java index c8e6cd1adf..94f59f7f4c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/planeswalker/JaceTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/planeswalker/JaceTest.java @@ -69,4 +69,34 @@ public class JaceTest extends CardTestPlayerBase { } + /** + * I know it's been a bit a rules question recently but I believe flip + * planeswalkers shouldn't be exiled by Containment priest when flipping as + * happens when using xmage (at least with Jace). + */ + @Test + public void testContainmentPriestWithFlipPlaneswalker() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); + addCard(Zone.GRAVEYARD, playerA, "Mountain", 4); + + // {T}: Draw a card, then discard a card. If there are five or more cards in your graveyard, + // exile Jace, Vryn's Prodigy, then return him to the battefield transformed under his owner's control. + addCard(Zone.BATTLEFIELD, playerA, "Jace, Vryn's Prodigy", 1); // {2}{R} - 3/2 + addCard(Zone.HAND, playerA, "Pillarfield Ox", 1); + + // Flash + // If a nontoken creature would enter the battlefield and it wasn't cast, exile it instead. + addCard(Zone.BATTLEFIELD, playerB, "Containment Priest", 1); // {2}{U}{U} + + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw a card"); + setChoice(playerA, "Pillarfield Ox"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Pillarfield Ox", 1); + assertExileCount("Jace, Vryn's Prodigy", 0); + assertPermanentCount(playerA, "Jace, Telepath Unbound", 1); + + } }