From 44f3ac8117cd88fd1e50b196399a33aaa0719822 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 31 Jan 2015 00:17:28 +0100 Subject: [PATCH] Some more fixes to cards looping through players. --- .../src/mage/sets/bornofthegods/WhimsOfTheFates.java | 5 ++++- .../src/mage/sets/shadowmoor/PlagueOfVermin.java | 10 +++++----- Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java | 6 +++--- .../mage/sets/vintagemasters/CouncilsJudgment.java | 4 ++-- Mage.Sets/src/mage/sets/vintagemasters/Eureka.java | 11 ++++++----- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Mage.Sets/src/mage/sets/bornofthegods/WhimsOfTheFates.java b/Mage.Sets/src/mage/sets/bornofthegods/WhimsOfTheFates.java index 05e25ebbf81..6333d9a778d 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/WhimsOfTheFates.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/WhimsOfTheFates.java @@ -101,7 +101,7 @@ class WhimsOfTheFateEffect extends OneShotEffect { // Map of players and their piles (1,2,3) with values of UUID of the permanents Map>> playerPermanents = new LinkedHashMap<>(); - PlayerList playerList = game.getState().getPlayerList(); + PlayerList playerList = game.getState().getPlayerList().copy(); while (!playerList.get().equals(source.getControllerId()) && controller.isInGame()) { playerList.getNext(); } @@ -117,6 +117,9 @@ class WhimsOfTheFateEffect extends OneShotEffect { if (firstNextPlayer == null) { firstNextPlayer = nextPlayer.getId(); } + if (!nextPlayer.isInGame()) { + continue; + } // if player is in range of controller he chooses 3 piles with all its permanents if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) { Map> playerPiles = new HashMap<>(); diff --git a/Mage.Sets/src/mage/sets/shadowmoor/PlagueOfVermin.java b/Mage.Sets/src/mage/sets/shadowmoor/PlagueOfVermin.java index 1a01594340f..259966b2f4d 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/PlagueOfVermin.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/PlagueOfVermin.java @@ -93,7 +93,7 @@ class PlagueOfVerminEffect extends OneShotEffect { int currentLifePaid; int totalPaidLife; if (controller != null) { - PlayerList playerList = game.getState().getPlayerList(); + PlayerList playerList = game.getState().getPlayerList().copy(); while (!playerList.get().equals(source.getControllerId()) && controller.isInGame()) { playerList.getNext(); } @@ -101,10 +101,10 @@ class PlagueOfVerminEffect extends OneShotEffect { UUID firstInactivePlayer = null; while (controller.isInGame()) { - if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) { - if (firstInactivePlayer == null) { - firstInactivePlayer = currentPlayer.getId(); - } + if (firstInactivePlayer == null) { + firstInactivePlayer = currentPlayer.getId(); + } + if (currentPlayer != null && currentPlayer.isInGame() && controller.getInRange().contains(currentPlayer.getId())) { currentLifePaid = 0; totalPaidLife = 0; if (currentPlayer.chooseUse(Outcome.AIDontUseIt, "Pay life?", game)) { diff --git a/Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java b/Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java index 837db7138a8..1a3d5084ec5 100644 --- a/Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java +++ b/Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java @@ -101,7 +101,7 @@ class HypergenesisEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - PlayerList playerList = game.getState().getPlayerList(); + PlayerList playerList = game.getState().getPlayerList().copy(); while (!playerList.get().equals(source.getControllerId()) && controller.isInGame()) { playerList.getNext(); } @@ -109,8 +109,8 @@ class HypergenesisEffect extends OneShotEffect { UUID firstInactivePlayer = null; Target target = new TargetCardInHand(filter); - while (controller.isInGame()) { - if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) { + while (controller.isInGame()) { + if (currentPlayer != null && currentPlayer.isInGame() && controller.getInRange().contains(currentPlayer.getId())) { if (firstInactivePlayer == null) { firstInactivePlayer = currentPlayer.getId(); } diff --git a/Mage.Sets/src/mage/sets/vintagemasters/CouncilsJudgment.java b/Mage.Sets/src/mage/sets/vintagemasters/CouncilsJudgment.java index aa41259f026..7377e55e646 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/CouncilsJudgment.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/CouncilsJudgment.java @@ -99,13 +99,13 @@ class CouncilsJudgmentEffect extends OneShotEffect { FilterNonlandPermanent filter = new FilterNonlandPermanent("a nonland permanent " + controller.getName() + " doesn't control"); filter.add(Predicates.not(new ControllerIdPredicate(controller.getId()))); //Players each choose a legal permanent - PlayerList playerList = game.getState().getPlayerList(); + PlayerList playerList = game.getState().getPlayerList().copy(); while (!playerList.get().equals(controller.getId()) && controller.isInGame()) { playerList.getNext(); } do { Player player = game.getPlayer(playerList.get()); - if (player != null) { + if (player != null && player.isInGame()) { Target target = new TargetNonlandPermanent(filter); target.setNotTarget(true); if (player.choose(Outcome.Exile, target, source.getSourceId(), game)) { diff --git a/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java b/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java index f1fc1c86144..b530d5e34dd 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java @@ -89,7 +89,7 @@ class EurekaEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - PlayerList playerList = game.getState().getPlayerList(); + PlayerList playerList = game.getState().getPlayerList().copy(); while (!playerList.get().equals(source.getControllerId()) && controller.isInGame()) { playerList.getNext(); } @@ -98,10 +98,11 @@ class EurekaEffect extends OneShotEffect { Target target = new TargetCardInHand(new FilterPermanentCard()); while (controller.isInGame()) { - if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) { - if (firstInactivePlayer == null) { - firstInactivePlayer = currentPlayer.getId(); - } + if (firstInactivePlayer == null) { + firstInactivePlayer = currentPlayer.getId(); + } + if (currentPlayer != null && currentPlayer.isInGame() && controller.getInRange().contains(currentPlayer.getId())) { + target.clearChosen(); if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game) && currentPlayer.chooseUse(outcome, "Put permanent from your hand to play?", game)) {