From 32ab0aadb00505712e00070fa7346e79519a4635 Mon Sep 17 00:00:00 2001 From: "Jamin W. Collins" Date: Wed, 26 Sep 2018 17:26:03 -0600 Subject: [PATCH] fix NPE when there is nothing to choose from With the existing code, if a player cast Surgical Extraction targetting a card that only existed in the target player's graveyard (no copies in the players hand or library), an NPE would be thrown. Signed-off-by: Jamin W. Collins --- .../java/forge/game/ability/effects/ChangeZoneEffect.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index 749b72a277e..0c0d1be8836 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -892,9 +892,11 @@ public class ChangeZoneEffect extends SpellAbilityEffect { do { selectedCards = decider.getController().chooseCardsForZoneChange(destination, origin, sa, fetchList, delayedReveal, selectPrompt, decider); } while (selectedCards != null && selectedCards.size() > changeNum); - for (Card card : selectedCards) { - chosenCards.add(card); - }; + if (selectedCards != null) { + for (Card card : selectedCards) { + chosenCards.add(card); + } + } // maybe prompt the user if they selected fewer than the maximum possible? } else { // one at a time