diff --git a/Mage.Sets/src/mage/sets/avacynrestored/DevastationTide.java b/Mage.Sets/src/mage/sets/avacynrestored/DevastationTide.java index 2a13b1ecf80..126fc303e65 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/DevastationTide.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/DevastationTide.java @@ -27,20 +27,23 @@ */ package mage.sets.avacynrestored; +import java.util.LinkedHashSet; +import java.util.Set; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.MiracleAbility; +import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.common.FilterNonlandPermanent; import mage.game.Game; import mage.game.permanent.Permanent; - +import mage.players.Player; /** * @@ -52,7 +55,6 @@ public class DevastationTide extends CardImpl { super(ownerId, 48, "Devastation Tide", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{U}{U}"); this.expansionSetCode = "AVR"; - // Return all nonland permanents to their owners' hands. this.getSpellAbility().addEffect(new DevastationTideEffect()); @@ -83,10 +85,17 @@ class DevastationTideEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) { - creature.moveToZone(Zone.HAND, source.getSourceId(), game, true); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Set cardsToHand = new LinkedHashSet<>(); + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) { + cardsToHand.add((Card) permanent); + } + controller.moveCards(cardsToHand, null, Zone.HAND, source, game); + return true; + } - return true; + return false; } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/DevastationTideTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/DevastationTideTest.java new file mode 100644 index 00000000000..e9ddc239d89 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/DevastationTideTest.java @@ -0,0 +1,77 @@ +/* + * 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.abilities.other; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class DevastationTideTest extends CardTestPlayerBase { + + @Test + public void testReturnNonLandPermanents() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); + addCard(Zone.HAND, playerA, "Devastation Tide"); // {3}{U}{U} + + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // Creature + addCard(Zone.BATTLEFIELD, playerA, "Vampiric Rites"); // Enchantment + addCard(Zone.BATTLEFIELD, playerA, "Hedron Archive"); // Artifact + addCard(Zone.BATTLEFIELD, playerA, "Karn Liberated"); // Planeswalker + addCard(Zone.BATTLEFIELD, playerA, "Nimbus Maze", 1); // Land + + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // Creature + addCard(Zone.BATTLEFIELD, playerB, "Vampiric Rites"); // Enchantment + addCard(Zone.BATTLEFIELD, playerB, "Hedron Archive"); // Artifact + addCard(Zone.BATTLEFIELD, playerB, "Karn Liberated"); // Planeswalker + addCard(Zone.BATTLEFIELD, playerB, "Nimbus Maze", 1); // Land + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Devastation Tide"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertHandCount(playerA, "Silvercoat Lion", 1); + assertHandCount(playerA, "Vampiric Rites", 1); + assertHandCount(playerA, "Hedron Archive", 1); + assertHandCount(playerA, "Karn Liberated", 1); + assertHandCount(playerA, "Nimbus Maze", 0); + + assertHandCount(playerB, "Silvercoat Lion", 1); + assertHandCount(playerB, "Vampiric Rites", 1); + assertHandCount(playerB, "Hedron Archive", 1); + assertHandCount(playerB, "Karn Liberated", 1); + assertHandCount(playerB, "Nimbus Maze", 0); + + } + +}