From a7e4ceb234e4f15e66a195b6fd9038ea64d9c101 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 11 Mar 2015 16:25:53 +0100 Subject: [PATCH] * Parallax Wave - Fixed a bug that always all exiled objects returned also if they were exiled by an earlier instance of Parallax Wave (combo with Opalescence). --- .../src/mage/sets/nemesis/ParallaxWave.java | 28 +++-- .../mage/sets/urzasdestiny/Opalescence.java | 4 +- .../test/cards/single/ParallaxWaveTest.java | 107 ++++++++++++++++++ 3 files changed, 126 insertions(+), 13 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/ParallaxWaveTest.java diff --git a/Mage.Sets/src/mage/sets/nemesis/ParallaxWave.java b/Mage.Sets/src/mage/sets/nemesis/ParallaxWave.java index d398fbcdc7b..2bf3c7107d1 100644 --- a/Mage.Sets/src/mage/sets/nemesis/ParallaxWave.java +++ b/Mage.Sets/src/mage/sets/nemesis/ParallaxWave.java @@ -28,12 +28,13 @@ package mage.sets.nemesis; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.ExileTargetEffect; +import mage.abilities.effects.common.ExileTargetForSourceEffect; import mage.abilities.keyword.FadingAbility; import mage.cards.Card; import mage.cards.CardImpl; @@ -46,6 +47,7 @@ import mage.game.ExileZone; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCreaturePermanent; +import mage.util.CardUtil; /** * @@ -63,7 +65,7 @@ public class ParallaxWave extends CardImpl { this.addAbility(new FadingAbility(5, this)); // Remove a fade counter from Parallax Wave: Exile target creature. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetEffect(this.getId(), this.getName()), new RemoveCountersSourceCost(CounterType.FADE.createInstance())); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetForSourceEffect(), new RemoveCountersSourceCost(CounterType.FADE.createInstance())); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); @@ -100,16 +102,22 @@ class ParallaxWaveEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - ExileZone exileZone = game.getExile().getExileZone(source.getSourceId()); - if (exileZone != null) { - for (Card card: exileZone.getCards(game)) { - Player player = game.getPlayer(card.getOwnerId()); - if (player != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); + MageObject sourceObject = source.getSourceObject(game); + if (sourceObject != null) { + UUID exileZoneId = CardUtil.getObjectExileZoneId(game, sourceObject); + if (exileZoneId != null) { + ExileZone exileZone = game.getExile().getExileZone(exileZoneId); + if (exileZone != null) { + for (Card card: exileZone.getCards(game)) { + Player player = game.getPlayer(card.getOwnerId()); + if (player != null) { + player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); + } + } + exileZone.clear(); } + return true; } - exileZone.clear(); - return true; } return false; } diff --git a/Mage.Sets/src/mage/sets/urzasdestiny/Opalescence.java b/Mage.Sets/src/mage/sets/urzasdestiny/Opalescence.java index bb8b0448d10..f7d78f067d9 100644 --- a/Mage.Sets/src/mage/sets/urzasdestiny/Opalescence.java +++ b/Mage.Sets/src/mage/sets/urzasdestiny/Opalescence.java @@ -27,9 +27,7 @@ */ package mage.sets.urzasdestiny; -import java.util.Iterator; import java.util.UUID; -import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousEffectImpl; @@ -87,7 +85,7 @@ class OpalescenceEffect extends ContinuousEffectImpl { public OpalescenceEffect() { super(Duration.WhileOnBattlefield, Outcome.BecomeCreature); - staticText = "Each other non-Aura enchantment is a creature with power and toughness each equal to its converted mana cost."; + staticText = "Each other non-Aura enchantment is a creature with power and toughness each equal to its converted mana cost"; } public OpalescenceEffect(final OpalescenceEffect effect) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/ParallaxWaveTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/ParallaxWaveTest.java new file mode 100644 index 00000000000..9e0cf706314 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/ParallaxWaveTest.java @@ -0,0 +1,107 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package org.mage.test.cards.single; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class ParallaxWaveTest extends CardTestPlayerBase { + + /** + * http://www.slightlymagic.net/forum/viewtopic.php?f=70&t=16732&hilit=Sharuum+the+Hegemon#p172791 + * + * While playing the AI I had put out Opalescence and Parallax Wave. + * With proper ordering of the stack I should be able to permanently exile all my + * opponents creatures. This does not happen + * + The proper sequence should work as follows + -Activate Parallax Wave to exile target enemy creature(s), + -Respond and assign Parallax Wave to target itself. + -Resolve the stack, Parallax wave targets itself for exile + -This triggers the return all exiled cards to the field effect, to the top of the stack + -Stack resolves, A "NEW unique id" parallax wave should enter the field. **this is not happening** + -The stack should finish resolution, the enemy creatures are exiled *however* the return to the + battle field effect should be tied to the ORIGINAL id Parallax Wave and thus will never trigger as + the original wave no longer exists) **this doesn't happen, as the "NEW" Parallax Wave leaves play + the cards exiled with the "previous" wave are returned to the battlefield** + + */ + @Test + public void testFirstExileHandlingOfItself() { + addCard(Zone.BATTLEFIELD, playerA, "Opalescence"); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 4); + addCard(Zone.HAND, playerA, "Parallax Wave"); + + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Parallax Wave"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Remove a fade counter from {this}: Exile target creature", "Silvercoat Lion"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Remove a fade counter from {this}: Exile target creature", "Parallax Wave"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Parallax Wave", 1); + assertCounterCount("Parallax Wave", CounterType.FADE, 5); + assertExileCount("Silvercoat Lion", 1); // The lion is still exiled + + } + + @Test + public void testFirstAndSecondExileHandlingOfItself() { + addCard(Zone.BATTLEFIELD, playerA, "Opalescence"); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 4); + addCard(Zone.HAND, playerA, "Parallax Wave"); + + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1); + addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Parallax Wave"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Remove a fade counter from {this}: Exile target creature", "Silvercoat Lion"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Remove a fade counter from {this}: Exile target creature", "Parallax Wave"); + + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Remove a fade counter from {this}: Exile target creature", "Pillarfield Ox"); + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Remove a fade counter from {this}: Exile target creature", "Parallax Wave"); + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Parallax Wave", 1); + + assertCounterCount("Parallax Wave", CounterType.FADE, 5); + + assertExileCount("Silvercoat Lion", 1); // The Lion is exiled and never returns + assertExileCount("Pillarfield Ox", 1); // The Ox is exiled and never returns + + } +} \ No newline at end of file