From 1ccd2a1b04447937a724f74a2aa53977604eb611 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 24 Sep 2016 03:36:18 +0200 Subject: [PATCH] Some fixes to prevent null pointer exceptions. --- .../src/mage/sets/iceage/ZursWeirding.java | 32 +++++++++---------- .../src/mage/sets/kaladesh/DeadlockTrap.java | 2 +- .../shadowsoverinnistrad/ForkInTheRoad.java | 6 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Mage.Sets/src/mage/sets/iceage/ZursWeirding.java b/Mage.Sets/src/mage/sets/iceage/ZursWeirding.java index a82e7091ed..0c102475bc 100644 --- a/Mage.Sets/src/mage/sets/iceage/ZursWeirding.java +++ b/Mage.Sets/src/mage/sets/iceage/ZursWeirding.java @@ -45,7 +45,6 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.players.Player; -import mage.players.PlayerList; /** * @@ -103,31 +102,30 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl { Card card = player.getLibrary().getFromTop(game); if (card != null) { // reveals it instead - player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum()+"|"+game.getPhase().getType() +")", new CardsImpl(card), game); + player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum() + "|" + game.getPhase().getType() + ")", new CardsImpl(card), game); // Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard - PlayerList playerList = game.getPlayerList().copy(); - playerList.setCurrent(player.getId()); - Player currentPlayer = playerList.getNext(game); - String message = new StringBuilder("Pay 2 life to put ").append(card.getLogName()).append(" into graveyard?").toString(); - while (!currentPlayer.getId().equals(player.getId())) { - if (currentPlayer.canPayLifeCost() && - currentPlayer.getLife() >= 2 && - currentPlayer.chooseUse(Outcome.Benefit, message, source, game)) { - currentPlayer.loseLife(2, game); - player.moveCards(card, Zone.GRAVEYARD, source, game); -// game.getState().getRevealed().reset(); - return true; + String message = "Pay 2 life to put " + card.getLogName() + " into graveyard?"; + for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) { + if (playerId.equals(player.getId())) { + continue; + } + Player otherPlayer = game.getPlayer(playerId); + if (otherPlayer.canPayLifeCost() + && otherPlayer.getLife() >= 2 + && otherPlayer.chooseUse(Outcome.Benefit, message, source, game)) { + otherPlayer.loseLife(2, game); + player.moveCards(card, Zone.GRAVEYARD, source, game); + break; } - - currentPlayer = playerList.getNext(game); } -// game.getState().getRevealed().reset(); } + return true; } return false; } + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DRAW_CARD; diff --git a/Mage.Sets/src/mage/sets/kaladesh/DeadlockTrap.java b/Mage.Sets/src/mage/sets/kaladesh/DeadlockTrap.java index 1f4b221373..2e7cef7fed 100644 --- a/Mage.Sets/src/mage/sets/kaladesh/DeadlockTrap.java +++ b/Mage.Sets/src/mage/sets/kaladesh/DeadlockTrap.java @@ -93,7 +93,7 @@ class DeadlockTrapCantActivateEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return getTargetPointer().getFirst(game, source).equals(permanent.getId()); + return permanent.getId().equals(getTargetPointer().getFirst(game, source)); } @Override diff --git a/Mage.Sets/src/mage/sets/shadowsoverinnistrad/ForkInTheRoad.java b/Mage.Sets/src/mage/sets/shadowsoverinnistrad/ForkInTheRoad.java index 7148db9147..a29c651c24 100644 --- a/Mage.Sets/src/mage/sets/shadowsoverinnistrad/ForkInTheRoad.java +++ b/Mage.Sets/src/mage/sets/shadowsoverinnistrad/ForkInTheRoad.java @@ -100,8 +100,10 @@ class ForkInTheRoadEffect extends OneShotEffect { if (target.getTargets().size() > 0) { Cards revealed = new CardsImpl(); for (UUID cardId : target.getTargets()) { - Card card = controller.getLibrary().getCard(cardId, game); - revealed.add(card); + Card card = game.getCard(cardId); + if (card != null) { + revealed.add(card); + } } controller.revealCards(sourceObject.getIdName(), revealed, game); if (target.getTargets().size() > 0) {