diff --git a/Mage.Sets/src/mage/cards/s/SacredGround.java b/Mage.Sets/src/mage/cards/s/SacredGround.java index fbee5573c32..53acd31aa77 100644 --- a/Mage.Sets/src/mage/cards/s/SacredGround.java +++ b/Mage.Sets/src/mage/cards/s/SacredGround.java @@ -48,8 +48,7 @@ import mage.target.targetpointer.FixedTarget; public class SacredGround extends CardImpl { public SacredGround(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}"); - + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); // Whenever a spell or ability an opponent controls causes a land to be put into your graveyard from the battlefield, return that card to the battlefield. this.addAbility(new SacredGroundTriggeredAbility()); @@ -92,7 +91,7 @@ class SacredGroundTriggeredAbility extends TriggeredAbilityImpl { if (Zone.BATTLEFIELD.equals(zce.getFromZone()) && Zone.GRAVEYARD.equals(zce.getToZone())) { Permanent targetPermanent = zce.getTarget(); if (targetPermanent.getCardType().contains(CardType.LAND) && targetPermanent.getControllerId().equals(getControllerId())) { - getEffects().get(0).setTargetPointer(new FixedTarget(targetPermanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(targetPermanent.getId(), game.getState().getZoneChangeCounter(targetPermanent.getId()))); return true; } } @@ -104,4 +103,4 @@ class SacredGroundTriggeredAbility extends TriggeredAbilityImpl { public String getRule() { return "Whenever a spell or ability an opponent controls causes a land to be put into your graveyard from the battlefield, " + super.getRule(); } -} \ No newline at end of file +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SacredGroundTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SacredGroundTest.java index 6c6ce282b88..1fa82368c50 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SacredGroundTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SacredGroundTest.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package org.mage.test.cards.triggers; import mage.constants.PhaseStep; @@ -40,10 +39,9 @@ import org.mage.test.serverside.base.CardTestPlayerBase; public class SacredGroundTest extends CardTestPlayerBase { /** - * Sacred Ground {1}{W} - * Enchantment - * Whenever a spell or ability an opponent controls causes a land to be put into your - * graveyard from the battlefield, return that card to the battlefield. + * Sacred Ground {1}{W} Enchantment Whenever a spell or ability an opponent + * controls causes a land to be put into your graveyard from the + * battlefield, return that card to the battlefield. * * * Destroyed land returns to battlefield @@ -76,10 +74,9 @@ public class SacredGroundTest extends CardTestPlayerBase { } /** - * Sacred Ground {1}{W} - * Enchantment - * Whenever a spell or ability an opponent controls causes a land to be put into your - * graveyard from the battlefield, return that card to the battlefield. + * Sacred Ground {1}{W} Enchantment Whenever a spell or ability an opponent + * controls causes a land to be put into your graveyard from the + * battlefield, return that card to the battlefield. * * * Destroyed land returns to battlefield @@ -111,10 +108,9 @@ public class SacredGroundTest extends CardTestPlayerBase { } /** - * Sacred Ground {1}{W} - * Enchantment - * Whenever a spell or ability an opponent controls causes a land to be put into your - * graveyard from the battlefield, return that card to the battlefield. + * Sacred Ground {1}{W} Enchantment Whenever a spell or ability an opponent + * controls causes a land to be put into your graveyard from the + * battlefield, return that card to the battlefield. * * * Destroyed land returns to battlefield @@ -144,4 +140,45 @@ public class SacredGroundTest extends CardTestPlayerBase { assertLife(playerB, 24); // + 2 * 2 life from Kabira Crossroads } + /** + * I was playing against Sacred Ground. I Molten Rained oponents land and + * responded Sacred Ground trigger by exiling it with Surgical Extraction. + * Then after that resolved, Sacred Ground ability put the land from exile + * onto the battfield! Fix this, please + */ + @Test + public void testWithSurgicalExtraction() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); + + // Destroy target land. + // If that land was nonbasic, Molten Rain deals 2 damage to the land's controller. + addCard(Zone.HAND, playerA, "Molten Rain");// Instant {1}{R}{R} + // Choose target card in a graveyard other than a basic land card. Search its owner's graveyard, + // hand, and library for any number of cards with the same name as that card and exile them. + // Then that player shuffles his or her library. + addCard(Zone.HAND, playerA, "Surgical Extraction"); // Instant {BP} + + addCard(Zone.BATTLEFIELD, playerB, "Caves of Koilos", 1); + /** + * Whenever a spell or ability an opponent controls causes a land to be + * put into your graveyard from the battlefield, return that card to the + * battlefield. + */ + addCard(Zone.BATTLEFIELD, playerB, "Sacred Ground"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Molten Rain", "Caves of Koilos"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Surgical Extraction", "Caves of Koilos"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Molten Rain", 1); + assertGraveyardCount(playerA, "Surgical Extraction", 1); + assertExileCount("Caves of Koilos", 1); + + assertLife(playerA, 20); + assertLife(playerB, 18); + } + }