diff --git a/Mage.Sets/src/mage/cards/m/MirrorGolem.java b/Mage.Sets/src/mage/cards/m/MirrorGolem.java index 731db559799..c90a7efde34 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorGolem.java +++ b/Mage.Sets/src/mage/cards/m/MirrorGolem.java @@ -76,7 +76,9 @@ class MirrorGolemImprintEffect extends OneShotEffect { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); if (card != null) { - controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), source.getSourceObject(game).getIdName()); + UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), sourcePermanent.getZoneChangeCounter(game)); + String exileZoneName = source.getSourceObject(game).getIdName(); + controller.moveCardsToExile(card, source, game, true, exileZoneId, exileZoneName); if (sourcePermanent != null) { sourcePermanent.imprint(this.getTargetPointer().getFirst(game, source), game); } @@ -102,9 +104,10 @@ class MirrorGolemEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanent(source.getSourceId()); - ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId())); + UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), sourceObject.getZoneChangeCounter(game)); + ExileZone exileZone = game.getExile().getExileZone(exileZoneId); - if (sourceObject == null || sourceObject.getImprinted() == null) { + if (sourceObject == null || sourceObject.getImprinted() == null || exileZone == null) { return false; } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/mrd/MirrorGolemTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/mrd/MirrorGolemTest.java new file mode 100644 index 00000000000..6403ba5502a --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/mrd/MirrorGolemTest.java @@ -0,0 +1,70 @@ +package org.mage.test.cards.single.mrd; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author Susucr + */ +public class MirrorGolemTest extends CardTestPlayerBase { + + /** + * {@link mage.cards.m.MirrorGolem Mirror Golem} {6} + * Artifact Creature — Golem + * Imprint — When this creature enters, you may exile target card from a graveyard. + * This creature has protection from each of the exiled card's card types. + * 3/4 + */ + private static final String golem = "Mirror Golem"; + + @Test + public void test_ProtectionSorcery() { + addCard(Zone.HAND, playerA, golem); + addCard(Zone.HAND, playerA, "Pyroclasm"); + addCard(Zone.GRAVEYARD, playerA, "Divination"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 8); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, golem); + addTarget(playerA, "Divination"); + setChoice(playerA, true); // yes to "you may exile" + + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pyroclasm"); + + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + setStrictChooseMode(true); + execute(); + + assertExileCount(playerA, "Divination", 1); + assertGraveyardCount(playerA, "Pyroclasm", 1); + assertDamageReceived(playerA, golem, 0); + } + + @Test + public void test_TokenCopy() { + addCard(Zone.BATTLEFIELD, playerA, golem); + addCard(Zone.HAND, playerA, "Relm's Sketching"); + addCard(Zone.HAND, playerA, "Storm's Wrath"); + addCard(Zone.GRAVEYARD, playerA, "Divination"); + addCard(Zone.BATTLEFIELD, playerA, "Volcanic Island", 8); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Relm's Sketching", golem); + addTarget(playerA, "Divination"); + setChoice(playerA, true); // yes to "you may exile" + + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Storm's Wrath"); + + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + setStrictChooseMode(true); + execute(); + + assertExileCount(playerA, "Divination", 1); + assertGraveyardCount(playerA, "Storm's Wrath", 1); + assertPermanentCount(playerA, golem, 1); + assertGraveyardCount(playerA, golem, 1); + assertDamageReceived(playerA, golem, 0); + } +}