diff --git a/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java b/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java index 9e97ea8e1b..e765b9a8e4 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java @@ -1,31 +1,30 @@ /* -* 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. -*/ - + * 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 mage.abilities.effects.common; import java.util.UUID; @@ -55,9 +54,9 @@ public class ReturnFromExileEffect extends OneShotEffect { this(exileId, zone, false); } - public ReturnFromExileEffect(UUID exileId, Zone zone, String text) { + public ReturnFromExileEffect(UUID exileId, Zone zone, String text) { this(exileId, zone, false); - staticText = text; + staticText = text; } public ReturnFromExileEffect(UUID exileId, Zone zone, boolean tapped) { @@ -65,7 +64,7 @@ public class ReturnFromExileEffect extends OneShotEffect { this.exileId = exileId; this.zone = zone; this.tapped = tapped; - setText(); + setText(); } public ReturnFromExileEffect(final ReturnFromExileEffect effect) { @@ -86,7 +85,7 @@ public class ReturnFromExileEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && exile != null) { exile = exile.copy(); - for (UUID cardId: exile) { + for (UUID cardId : exile) { Card card = game.getCard(cardId); Player owner = game.getPlayer(card.getOwnerId()); if (owner != null) { @@ -119,7 +118,7 @@ public class ReturnFromExileEffect extends OneShotEffect { private void setText() { StringBuilder sb = new StringBuilder(); sb.append("return the exiled cards "); - switch(zone) { + switch (zone) { case BATTLEFIELD: sb.append("to the battlefield under its owner's control"); if (tapped) { diff --git a/Mage/src/mage/abilities/effects/common/ScryEffect.java b/Mage/src/mage/abilities/effects/common/ScryEffect.java index d5dd6fdc42..429bbf93bf 100644 --- a/Mage/src/mage/abilities/effects/common/ScryEffect.java +++ b/Mage/src/mage/abilities/effects/common/ScryEffect.java @@ -49,7 +49,6 @@ import mage.util.CardUtil; public class ScryEffect extends OneShotEffect { protected static FilterCard filter1 = new FilterCard("card to put on the bottom of your library"); - protected static FilterCard filter2 = new FilterCard("card to put on the top of your library (last chosen will be on top)"); protected int scryNumber; @@ -91,22 +90,7 @@ public class ScryEffect extends OneShotEffect { target1.clearChosen(); } // move cards to the top of the library - if (cards.size() > 1) { - TargetCard target2 = new TargetCard(Zone.LIBRARY, filter2); - while (player.isInGame() && cards.size() > 1) { - player.choose(Outcome.Benefit, cards, target2, game); - Card card = cards.get(target2.getFirstTarget(), game); - if (card != null) { - cards.remove(card); - player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, true, false); - } - target2.clearChosen(); - } - } - if (cards.size() == 1) { - Card card = cards.get(cards.iterator().next(), game); - player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, true, false); - } + player.putCardsOnTopOfLibrary(cards, game, source, true); game.fireEvent(new GameEvent(GameEvent.EventType.SCRY, source.getControllerId(), source.getSourceId(), source.getControllerId())); player.setTopCardRevealed(revealed); return true; diff --git a/Mage/src/mage/game/draft/DraftCube.java b/Mage/src/mage/game/draft/DraftCube.java index de1ba64e4d..40f69ffcbb 100644 --- a/Mage/src/mage/game/draft/DraftCube.java +++ b/Mage/src/mage/game/draft/DraftCube.java @@ -74,8 +74,8 @@ public abstract class DraftCube { private final String name; private final int boosterSize = 15; - protected List cubeCards = new ArrayList(); - protected List leftCubeCards = new ArrayList(); + protected List cubeCards = new ArrayList<>(); + protected List leftCubeCards = new ArrayList<>(); public DraftCube(String name) { this.name = name; @@ -90,7 +90,7 @@ public abstract class DraftCube { } public List createBooster() { - List booster = new ArrayList(); + List booster = new ArrayList<>(); if (leftCubeCards.isEmpty()) { leftCubeCards.addAll(cubeCards); } diff --git a/Mage/src/mage/game/draft/DraftImpl.java b/Mage/src/mage/game/draft/DraftImpl.java index 3093c69e1a..8f6712a51b 100644 --- a/Mage/src/mage/game/draft/DraftImpl.java +++ b/Mage/src/mage/game/draft/DraftImpl.java @@ -29,7 +29,6 @@ package mage.game.draft; import java.util.Collection; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index e415a7a1c9..53ee3fffd0 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -297,7 +297,7 @@ public interface Player extends MageItem, Copyable { boolean playMana(ManaCost unpaid, Game game); /** - * Moves the cards form to the bottom of the players library. + * Moves the cards from cards to the bottom of the players library. * * @param cards - list of cards that have to be moved * @param game - game @@ -307,6 +307,17 @@ public interface Player extends MageItem, Copyable { */ boolean putCardsOnBottomOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder); + /** + * Moves the cards from cards to the top of players library. + * + * @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 + * @param source - source ability + * @return + */ + boolean putCardsOnTopOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder); + // set the value for X mana spells and abilities int announceXMana(int min, int max, String message, Game game, Ability ability); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 4fab433469..6d4e88b98e 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -804,6 +804,41 @@ public abstract class PlayerImpl implements Player, Serializable { return true; } + @Override + public boolean putCardsOnTopOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder) { + if (cards.size() != 0) { + if (!anyOrder) { + for (UUID cardId : cards) { + Card card =game.getCard(cardId); + + if (card != null) { + Zone fromZone = game.getState().getZone(cardId); + this.moveCardToLibraryWithInfo(card, source.getSourceId(), game, fromZone, true, false); + } + } + } else { + TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the top of your library (last one chosen will be topmost)")); + target.setRequired(true); + while (isInGame() && cards.size() > 1) { + this.choose(Outcome.Neutral, cards, target, game); + Card chosenCard = cards.get(target.getFirstTarget(), game); + if (chosenCard != null) { + cards.remove(chosenCard); + Zone fromZone = game.getState().getZone(chosenCard.getId()); + this.moveCardToLibraryWithInfo(chosenCard, source.getSourceId(), game, fromZone, true, false); + } + target.clearChosen(); + } + if (cards.size() == 1) { + Card chosenCard = cards.get(cards.iterator().next(), game); + Zone fromZone = game.getState().getZone(chosenCard.getId()); + this.moveCardToLibraryWithInfo(chosenCard, source.getSourceId(), game, fromZone, true, false); + } + } + } + return true; + } + @Override public void setCastSourceIdWithoutMana(UUID sourceId) { castSourceIdWithoutMana = sourceId;