From d7c23bbfc02dd4786991354701be082e2bf9d708 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 1 May 2015 14:04:52 +0200 Subject: [PATCH] * Fixed a bug that countered spells of creatures with the ability going back to library if going to graveyard (e.g. Legacy Waepon) stayed in hand or caused a java bug instead of going to library. --- .../mage/sets/vintagemasters/ManaDrain.java | 2 +- .../ZoneChangeReplacementTest.java | 38 +++++++++++++++++++ ...vealAndShuffleIntoLibrarySourceEffect.java | 4 ++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/sets/vintagemasters/ManaDrain.java b/Mage.Sets/src/mage/sets/vintagemasters/ManaDrain.java index 1561ea5d21..4e794b2e84 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/ManaDrain.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/ManaDrain.java @@ -56,7 +56,7 @@ public class ManaDrain extends CardImpl { this.expansionSetCode = "VMA"; this.color.setBlue(true); - + // Counter target spell. At the beginning of your next main phase, add {X} to your mana pool, where X is that spell's converted mana cost. this.getSpellAbility().addTarget(new TargetSpell()); this.getSpellAbility().addEffect(new ManaDrainCounterEffect()); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ZoneChangeReplacementTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ZoneChangeReplacementTest.java index bd0cab05be..cd71b3de77 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ZoneChangeReplacementTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ZoneChangeReplacementTest.java @@ -30,6 +30,7 @@ package org.mage.test.cards.replacement; import mage.constants.PhaseStep; import mage.constants.Zone; +import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -286,6 +287,43 @@ public class ZoneChangeReplacementTest extends CardTestPlayerBase { assertGraveyardCount(playerB, "Pillarfield Ox", 1); } + /** + * Test that a countered spell of a card that goes always to library back + * instead of into the graveyard. + */ + + @Test + public void testCounterAndMoveToLibrary() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 7); + // Legacy Weapon - Artifact {7} + // {W}{U}{B}{R}{G}: Exile target permanent. + // If Legacy Weapon would be put into a graveyard from anywhere, reveal Legacy Weapon and shuffle it into its owner's library instead. + addCard(Zone.HAND, playerA, "Legacy Weapon"); + + addCard(Zone.BATTLEFIELD, playerB, "Island", 2); + // Counter target spell. At the beginning of your next main phase, add {X} to your mana pool, where X is that spell's converted mana cost. + addCard(Zone.HAND, playerB, "Mana Drain"); + addCard(Zone.HAND, playerB, "Legacy Weapon"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Legacy Weapon"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Mana Drain", "Legacy Weapon"); + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Legacy Weapon"); + setStopAt(2, PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertHandCount(playerA, "Legacy Weapon", 0); + assertPermanentCount(playerA, "Legacy Weapon", 0); + assertGraveyardCount(playerA, "Legacy Weapon", 0); + + assertGraveyardCount(playerB, "Mana Drain", 1); + + assertPermanentCount(playerB, "Legacy Weapon", 1); + + } } diff --git a/Mage/src/mage/abilities/effects/common/RevealAndShuffleIntoLibrarySourceEffect.java b/Mage/src/mage/abilities/effects/common/RevealAndShuffleIntoLibrarySourceEffect.java index 6e08d58cc9..f13a8e9d98 100644 --- a/Mage/src/mage/abilities/effects/common/RevealAndShuffleIntoLibrarySourceEffect.java +++ b/Mage/src/mage/abilities/effects/common/RevealAndShuffleIntoLibrarySourceEffect.java @@ -39,6 +39,7 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentCard; +import mage.game.stack.Spell; import mage.players.Player; /** @@ -65,6 +66,9 @@ public class RevealAndShuffleIntoLibrarySourceEffect extends OneShotEffect { Player owner = null; Cards cards = new CardsImpl(); Permanent permanent = null; + if (sourceObject instanceof Spell) { + sourceObject = ((Spell)sourceObject).getCard(); + } if (sourceObject instanceof Permanent) { permanent = (Permanent) sourceObject; owner = game.getPlayer(permanent.getOwnerId());