diff --git a/Mage.Sets/src/mage/cards/a/AshioksErasure.java b/Mage.Sets/src/mage/cards/a/AshioksErasure.java index d5b3ccd6d19..f72c3b0bcaa 100644 --- a/Mage.Sets/src/mage/cards/a/AshioksErasure.java +++ b/Mage.Sets/src/mage/cards/a/AshioksErasure.java @@ -25,6 +25,7 @@ import mage.players.Player; import mage.target.TargetSpell; import mage.util.CardUtil; +import java.util.Set; import java.util.UUID; /** @@ -133,10 +134,17 @@ class AshioksErasureReplacementEffect extends ContinuousRuleModifyingEffectImpl exile = game.getExile().getExileZone(exileZone); } } + if (exile == null) { return false; } - Card exiledCard = exile.getCards(game).iterator().next(); + + Set cards = exile.getCards(game); + if (cards.isEmpty()) { + return false; + } + + Card exiledCard = cards.iterator().next(); if (exiledCard != null) { return exiledCard.getName().equals(card.getName()); } diff --git a/Mage.Sets/src/mage/cards/a/AugurOfBolas.java b/Mage.Sets/src/mage/cards/a/AugurOfBolas.java index 085a7db0971..097fd8d5ef7 100644 --- a/Mage.Sets/src/mage/cards/a/AugurOfBolas.java +++ b/Mage.Sets/src/mage/cards/a/AugurOfBolas.java @@ -1,7 +1,5 @@ - package mage.cards.a; -import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -19,8 +17,10 @@ import mage.game.Game; import mage.players.Player; import mage.target.TargetCard; +import java.util.Set; +import java.util.UUID; + /** - * * @author jeffwadsworth */ public final class AugurOfBolas extends CardImpl { @@ -81,9 +81,12 @@ class AugurOfBolasEffect extends OneShotEffect { int number = topCards.count(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game); if (number > 0) { if (controller.chooseUse(outcome, "Reveal an instant or sorcery card from the looked at cards and put it into your hand?", source, game)) { - Card card; + Card card = null; if (number == 1) { - card = topCards.getCards(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game).iterator().next(); + Set cards = topCards.getCards(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game); + if (!cards.isEmpty()) { + card = cards.iterator().next(); + } } else { TargetCard target = new TargetCard(Zone.LIBRARY, new FilterInstantOrSorceryCard()); controller.chooseTarget(outcome, topCards, target, source, game); diff --git a/Mage.Sets/src/mage/cards/c/Cultivate.java b/Mage.Sets/src/mage/cards/c/Cultivate.java index 26e42118d32..aded78b57e2 100644 --- a/Mage.Sets/src/mage/cards/c/Cultivate.java +++ b/Mage.Sets/src/mage/cards/c/Cultivate.java @@ -1,7 +1,5 @@ - package mage.cards.c; -import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -16,8 +14,10 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; +import java.util.Set; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com */ public final class Cultivate extends CardImpl { @@ -79,12 +79,14 @@ class CultivateEffect extends OneShotEffect { controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); revealed.remove(card); } - card = revealed.getCards(game).iterator().next(); + Set cards = revealed.getCards(game); + card = cards.isEmpty() ? null : cards.iterator().next(); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); } } else if (target.getTargets().size() == 1) { - Card card = revealed.getCards(game).iterator().next(); + Set cards = revealed.getCards(game); + Card card = cards.isEmpty() ? null : cards.iterator().next(); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } diff --git a/Mage.Sets/src/mage/cards/f/FinalParting.java b/Mage.Sets/src/mage/cards/f/FinalParting.java index 2705156ea50..d89aae87b45 100644 --- a/Mage.Sets/src/mage/cards/f/FinalParting.java +++ b/Mage.Sets/src/mage/cards/f/FinalParting.java @@ -1,14 +1,8 @@ - package mage.cards.f; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -18,8 +12,10 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; +import java.util.Set; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class FinalParting extends CardImpl { @@ -78,10 +74,12 @@ class FinalPartingEffect extends OneShotEffect { Card card = searched.get(target2.getFirstTarget(), game); controller.moveCards(card, Zone.HAND, source, game); searched.remove(card); - card = searched.getCards(game).iterator().next(); + Set cards = searched.getCards(game); + card = cards.isEmpty() ? null : cards.iterator().next(); controller.moveCards(card, Zone.GRAVEYARD, source, game); } else if (target.getTargets().size() == 1) { - Card card = searched.getCards(game).iterator().next(); + Set cards = searched.getCards(game); + Card card = cards.isEmpty() ? null : cards.iterator().next(); controller.moveCards(card, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/g/GodEternalKefnet.java b/Mage.Sets/src/mage/cards/g/GodEternalKefnet.java index 9c0cdb15a2e..3aecf9aeb79 100644 --- a/Mage.Sets/src/mage/cards/g/GodEternalKefnet.java +++ b/Mage.Sets/src/mage/cards/g/GodEternalKefnet.java @@ -127,7 +127,7 @@ class GodEternalKefnetDrawCardReplacementEffect extends ReplacementEffectImpl { return false; } - Card topCard = you.getLibrary().getTopCards(game, 1).iterator().next(); + Card topCard = you.getLibrary().getFromTop(game); if (topCard == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/j/JaradsOrders.java b/Mage.Sets/src/mage/cards/j/JaradsOrders.java index bbee2a378bd..e0dc5903cfa 100644 --- a/Mage.Sets/src/mage/cards/j/JaradsOrders.java +++ b/Mage.Sets/src/mage/cards/j/JaradsOrders.java @@ -1,14 +1,8 @@ - package mage.cards.j; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -19,14 +13,16 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; +import java.util.Set; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class JaradsOrders extends CardImpl { public JaradsOrders(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{B}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}{G}"); // Search your library for up to two creature cards and reveal them. Put one into your hand and the other into your graveyard. Then shuffle your library. this.getSpellAbility().addEffect(new JaradsOrdersEffect()); @@ -41,6 +37,7 @@ public final class JaradsOrders extends CardImpl { return new JaradsOrders(this); } } + class JaradsOrdersEffect extends OneShotEffect { protected static final FilterCard filter = new FilterCard("card to put into your hand"); @@ -60,14 +57,14 @@ class JaradsOrdersEffect extends OneShotEffect { } @Override - public boolean apply(Game game, Ability source) { + public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterCreatureCard("creature cards")); if (controller.searchLibrary(target, source, game)) { if (!target.getTargets().isEmpty()) { Cards revealed = new CardsImpl(); - for (UUID cardId: target.getTargets()) { + for (UUID cardId : target.getTargets()) { Card card = controller.getLibrary().getCard(cardId, game); revealed.add(card); } @@ -78,10 +75,12 @@ class JaradsOrdersEffect extends OneShotEffect { Card card = revealed.get(target2.getFirstTarget(), game); controller.moveCards(card, Zone.HAND, source, game); revealed.remove(card); - card = revealed.getCards(game).iterator().next(); + Set cards = revealed.getCards(game); + card = cards.isEmpty() ? null : cards.iterator().next(); controller.moveCards(card, Zone.GRAVEYARD, source, game); } else if (target.getTargets().size() == 1) { - Card card = revealed.getCards(game).iterator().next(); + Set cards = revealed.getCards(game); + Card card = cards.isEmpty() ? null : cards.iterator().next(); controller.moveCards(card, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/k/KodamasReach.java b/Mage.Sets/src/mage/cards/k/KodamasReach.java index 853fd0da296..2b11b5d7751 100644 --- a/Mage.Sets/src/mage/cards/k/KodamasReach.java +++ b/Mage.Sets/src/mage/cards/k/KodamasReach.java @@ -1,4 +1,3 @@ - package mage.cards.k; import mage.MageObject; @@ -16,16 +15,16 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; +import java.util.Set; import java.util.UUID; /** - * * @author LevelX2 */ public final class KodamasReach extends CardImpl { public KodamasReach(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}"); this.subtype.add(SubType.ARCANE); // Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Then shuffle your library. @@ -84,12 +83,14 @@ class KodamasReachEffect extends OneShotEffect { controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); revealed.remove(card); } - card = revealed.getCards(game).iterator().next(); + Set cards = revealed.getCards(game); + card = cards.isEmpty() ? null : cards.iterator().next(); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); } } else if (target.getTargets().size() == 1) { - Card card = revealed.getCards(game).iterator().next(); + Set cards = revealed.getCards(game); + Card card = cards.isEmpty() ? null : cards.iterator().next(); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } diff --git a/Mage.Sets/src/mage/cards/m/MagusOfTheJar.java b/Mage.Sets/src/mage/cards/m/MagusOfTheJar.java index d76c8f3526b..f1c9c8778a1 100644 --- a/Mage.Sets/src/mage/cards/m/MagusOfTheJar.java +++ b/Mage.Sets/src/mage/cards/m/MagusOfTheJar.java @@ -1,8 +1,5 @@ - package mage.cards.m; -import java.util.Iterator; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; @@ -11,28 +8,26 @@ import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.players.Player; +import java.util.Iterator; +import java.util.UUID; + /** - * * @author HCrescent */ public final class MagusOfTheJar extends CardImpl { public MagusOfTheJar(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{U}"); - + this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.WIZARD); this.power = new MageInt(3); @@ -42,7 +37,7 @@ public final class MagusOfTheJar extends CardImpl { Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MagusoftheJarEffect(), new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); - + } public MagusOfTheJar(final MagusOfTheJar card) { @@ -73,9 +68,9 @@ class MagusoftheJarEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - Cards hand = player.getHand(); - while (!hand.isEmpty()) { - Card card = hand.get(hand.iterator().next(), game); + Cards handCards = new CardsImpl(player.getHand()); + for (UUID cardId : handCards) { + Card card = handCards.get(cardId, game); if (card != null) { card.moveToExile(getId(), "Magus of the Jar", source.getSourceId(), game); card.setFaceDown(true, game); @@ -133,7 +128,7 @@ class MagusoftheJarDelayedEffect extends OneShotEffect { } } //Return to hand - for (Iterator it = cards.getCards(game).iterator(); it.hasNext();) { + for (Iterator it = cards.getCards(game).iterator(); it.hasNext(); ) { Card card = it.next(); card.moveToZone(Zone.HAND, source.getSourceId(), game, true); } diff --git a/Mage.Sets/src/mage/cards/m/MemoryJar.java b/Mage.Sets/src/mage/cards/m/MemoryJar.java index c9937c675b2..8b1c6c052ad 100644 --- a/Mage.Sets/src/mage/cards/m/MemoryJar.java +++ b/Mage.Sets/src/mage/cards/m/MemoryJar.java @@ -1,8 +1,5 @@ - package mage.cards.m; -import java.util.Iterator; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; @@ -10,11 +7,7 @@ import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -23,14 +16,16 @@ import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.players.Player; +import java.util.Iterator; +import java.util.UUID; + /** - * * @author Plopman */ public final class MemoryJar extends CardImpl { public MemoryJar(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}"); // {T}, Sacrifice Memory Jar: Each player exiles all cards from their hand face down and draws seven cards. // At the beginning of the next end step, each player discards their hand and returns to their hand each @@ -69,9 +64,9 @@ class MemoryJarEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - Cards hand = player.getHand(); - while (!hand.isEmpty()) { - Card card = hand.get(hand.iterator().next(), game); + Cards handCards = new CardsImpl(player.getHand()); + for (UUID cardId : handCards) { + Card card = handCards.get(cardId, game); if (card != null) { card.moveToExile(getId(), "Memory Jar", source.getSourceId(), game); card.setFaceDown(true, game); @@ -129,7 +124,7 @@ class MemoryJarDelayedEffect extends OneShotEffect { } } //Return to hand - for (Iterator it = cards.getCards(game).iterator(); it.hasNext();) { + for (Iterator it = cards.getCards(game).iterator(); it.hasNext(); ) { Card card = it.next(); card.moveToZone(Zone.HAND, source.getSourceId(), game, true); } diff --git a/Mage.Sets/src/mage/cards/o/OathOfNissa.java b/Mage.Sets/src/mage/cards/o/OathOfNissa.java index 707f5da1111..9b91a352be7 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfNissa.java +++ b/Mage.Sets/src/mage/cards/o/OathOfNissa.java @@ -17,6 +17,7 @@ import mage.players.Player; import mage.target.TargetCard; import mage.util.CardUtil; +import java.util.Set; import java.util.UUID; /** @@ -83,7 +84,8 @@ class OathOfNissaEffect extends OneShotEffect { if (controller.chooseUse(outcome, "Reveal a creature, land, or planeswalker card from the looked at cards and put it into your hand?", source, game)) { Card card; if (number == 1) { - card = topCards.getCards(filter, source.getSourceId(), source.getControllerId(), game).iterator().next(); + Set cards = topCards.getCards(filter, source.getSourceId(), source.getControllerId(), game); + card = cards.isEmpty() ? null : cards.iterator().next(); } else { TargetCard target = new TargetCard(Zone.LIBRARY, filter); controller.choose(outcome, topCards, target, game); diff --git a/Mage.Sets/src/mage/cards/p/ParallelThoughts.java b/Mage.Sets/src/mage/cards/p/ParallelThoughts.java index 16306d9f348..9569d5cde66 100644 --- a/Mage.Sets/src/mage/cards/p/ParallelThoughts.java +++ b/Mage.Sets/src/mage/cards/p/ParallelThoughts.java @@ -1,22 +1,17 @@ package mage.cards.p; -import java.util.Arrays; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Zone; import mage.filter.FilterCard; +import mage.game.ExileZone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; @@ -26,8 +21,11 @@ import mage.target.common.TargetCardInLibrary; import mage.util.CardUtil; import mage.util.RandomUtil; +import java.util.Arrays; +import java.util.Set; +import java.util.UUID; + /** - * * @author jeffwadsworth */ public final class ParallelThoughts extends CardImpl { @@ -131,10 +129,11 @@ class ParallelThoughtsReplacementEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null - && !game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)).getCards(game).isEmpty()) { + ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); + Set cards = exileZone != null ? exileZone.getCards(game) : null; + if (controller != null && cards != null && !cards.isEmpty()) { if (controller.chooseUse(outcome, "Draw a card from the pile you exiled instead drawing from your library?", source, game)) { - Card card = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)).getCards(game).iterator().next(); + Card card = cards.iterator().next(); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/p/Peregrination.java b/Mage.Sets/src/mage/cards/p/Peregrination.java index 53d6f140457..724b6497abd 100644 --- a/Mage.Sets/src/mage/cards/p/Peregrination.java +++ b/Mage.Sets/src/mage/cards/p/Peregrination.java @@ -1,4 +1,3 @@ - package mage.cards.p; import mage.MageObject; @@ -17,16 +16,16 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; +import java.util.Set; import java.util.UUID; /** - * * @author LevelX2 */ public final class Peregrination extends CardImpl { public Peregrination(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}"); // Seach your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Shuffle your library, then scry 1. this.getSpellAbility().addEffect(new PeregrinationEffect()); @@ -85,10 +84,12 @@ class PeregrinationEffect extends OneShotEffect { Card card = revealed.get(target2.getFirstTarget(), game); controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); revealed.remove(card); - card = revealed.getCards(game).iterator().next(); + Set cards = revealed.getCards(game); + card = cards.isEmpty() ? null : cards.iterator().next(); controller.moveCards(card, Zone.HAND, source, game); } else if (target.getTargets().size() == 1) { - Card card = revealed.getCards(game).iterator().next(); + Set cards = revealed.getCards(game); + Card card = cards.isEmpty() ? null : cards.iterator().next(); controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java b/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java index 2aec1d0d7c7..82e095daec1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java @@ -1,7 +1,5 @@ - package mage.abilities.effects.common; -import java.util.UUID; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -13,9 +11,11 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.util.CardUtil; +import java.util.Set; +import java.util.UUID; + /** * @author LevelX2 - * */ public class HideawayPlayEffect extends OneShotEffect { @@ -40,12 +40,16 @@ public class HideawayPlayEffect extends OneShotEffect { if (permanent != null) { zone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), permanent.getZoneChangeCounter(game))); } - - if (zone == null - || zone.isEmpty()) { + + if (zone == null) { return true; } - Card card = zone.getCards(game).iterator().next(); + Set cards = zone.getCards(game); + if (cards.isEmpty()) { + return true; + } + + Card card = cards.iterator().next(); Player controller = game.getPlayer(source.getControllerId()); if (card != null && controller != null) { if (controller.chooseUse(Outcome.PlayForFree, "Do you want to play " + card.getIdName() + " for free now?", source, game)) { diff --git a/Mage/src/main/java/mage/game/ZonesHandler.java b/Mage/src/main/java/mage/game/ZonesHandler.java index bfc255ed9ee..d7bac4124be 100644 --- a/Mage/src/main/java/mage/game/ZonesHandler.java +++ b/Mage/src/main/java/mage/game/ZonesHandler.java @@ -285,6 +285,9 @@ public final class ZonesHandler { public static List chooseOrder(String message, Cards cards, Player player, Game game) { List order = new ArrayList<>(); + if (cards.isEmpty()) { + return order; + } TargetCard target = new TargetCard(Zone.ALL, new FilterCard(message)); target.setRequired(true); while (player.isInGame() && cards.size() > 1) {