diff --git a/Mage.Sets/src/mage/cards/p/PossibilityStorm.java b/Mage.Sets/src/mage/cards/p/PossibilityStorm.java index 30742acac95..8ebea656995 100644 --- a/Mage.Sets/src/mage/cards/p/PossibilityStorm.java +++ b/Mage.Sets/src/mage/cards/p/PossibilityStorm.java @@ -56,7 +56,7 @@ import mage.target.targetpointer.FixedTarget; public class PossibilityStorm extends CardImpl { public PossibilityStorm(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{R}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}{R}"); // Whenever a player casts a spell from his or her hand, that player exiles it, then exiles cards from // the top of his or her library until he or she exiles a card that shares a card type with it. That @@ -133,14 +133,14 @@ class PossibilityStormEffect extends OneShotEffect { if (sourceObject != null && spell != null) { Player spellController = game.getPlayer(spell.getControllerId()); if (spellController != null - && spellController.moveCardToExileWithInfo(spell, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.STACK, true)) { + && spellController.moveCardsToExile(spell, source, game, true, source.getSourceId(), sourceObject.getIdName())) { if (spellController.getLibrary().size() > 0) { Library library = spellController.getLibrary(); Card card; do { - card = library.removeFromTop(game); + card = library.getFromTop(game); if (card != null) { - spellController.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true); + spellController.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName()); } } while (library.size() > 0 && card != null && !sharesType(card, spell.getCardType())); @@ -154,10 +154,7 @@ class PossibilityStormEffect extends OneShotEffect { ExileZone exile = game.getExile().getExileZone(source.getSourceId()); if (exile != null) { - while (exile.size() > 0) { - card = exile.getRandom(game); - spellController.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, false, false); - } + spellController.putCardsOnBottomOfLibrary(exile, game, source, false); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/PossibilityStormTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/PossibilityStormTest.java index 84ef7030c2b..69403791c3a 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/PossibilityStormTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/PossibilityStormTest.java @@ -27,10 +27,8 @@ */ package org.mage.test.cards.triggers; -import mage.cards.Card; import mage.constants.PhaseStep; import mage.constants.Zone; -import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -61,7 +59,7 @@ public class PossibilityStormTest extends CardTestPlayerBase { // the top of his or her library until he or she exiles a card that shares a card type with it. That // player may cast that card without paying its mana cost. Then he or she puts all cards exiled with // Possibility Storm on the bottom of his or her library in a random order. - addCard(Zone.BATTLEFIELD, playerA, "Possibility Storm", 2); + addCard(Zone.BATTLEFIELD, playerA, "Possibility Storm", 1); // {T}: Add {C} to your mana pool. // Morph {2} @@ -78,14 +76,7 @@ public class PossibilityStormTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Zoetic Cavern", 0); - boolean zoeticCavernInLibrary = false; - for (Card card : playerA.getLibrary().getCards(currentGame)) { - if (card.getName().equals("Zoetic Cavern")) { - zoeticCavernInLibrary = true; - } - } - Assert.assertEquals("Zoetic Cavern has to be in the library", true, zoeticCavernInLibrary); - + assertLibraryCount(playerA, "Zoetic Cavern", 1); assertPermanentCount(playerA, "Silvercoat Lion", 1); } diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index 0f9638e302a..e915ac498a2 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -506,6 +506,7 @@ public interface Player extends MageItem, Copyable { * @param cards - list of cards that have to be moved * @param game - game * @param anyOrder - true if player can determine the order of the cards + * else random order * @param source - source ability * @return */ diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 70308b01bbe..5208ed7ad28 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -825,8 +825,10 @@ public abstract class PlayerImpl implements Player, Serializable { if (!cardsToLibrary.isEmpty()) { Cards cards = new CardsImpl(cardsToLibrary); // prevent possible ConcurrentModificationException if (!anyOrder) { - for (UUID objectId : cards) { - moveObjectToLibrary(objectId, source == null ? null : source.getSourceId(), game, false, false); + while (!cards.isEmpty()) { + UUID cardId = cards.getRandom(game).getId(); + cards.remove(cardId); + moveObjectToLibrary(cardId, source == null ? null : source.getSourceId(), game, false, false); } } else { TargetCard target = new TargetCard(Zone.ALL, new FilterCard("card to put on the bottom of your library (last one chosen will be bottommost)")); @@ -864,8 +866,10 @@ public abstract class PlayerImpl implements Player, Serializable { Cards cards = new CardsImpl(cardsToLibrary); // prevent possible ConcurrentModificationException UUID sourceId = (source == null ? null : source.getSourceId()); if (!anyOrder) { - for (UUID cardId : cards) { - moveObjectToLibrary(cardId, sourceId, game, true, false); + while (!cards.isEmpty()) { + UUID cardId = cards.getRandom(game).getId(); + cards.remove(cardId); + moveObjectToLibrary(cardId, source == null ? null : source.getSourceId(), game, true, false); } } else { TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on the top of your library (last one chosen will be topmost)"));