From aee9a3a41d6e6cbb83bbd0b0563434d6bf9a6101 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Thu, 26 May 2022 21:15:53 +0200 Subject: [PATCH] Fix NPE --- .../game/ability/effects/ControlGainEffect.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/ControlGainEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ControlGainEffect.java index 3436759e7d8..7c175cf83b4 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ControlGainEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ControlGainEffect.java @@ -118,24 +118,22 @@ public class ControlGainEffect extends SpellAbilityEffect { final Game game = newController.getGame(); CardCollectionView tgtCards = null; - if (sa.hasParam("ControlledByTarget")) { - tgtCards = CardLists.filterControlledBy(tgtCards, getTargetPlayers(sa)); - } else if (sa.hasParam("Choices")) { + if (sa.hasParam("Choices")) { Player chooser = sa.hasParam("Chooser") ? AbilityUtils.getDefinedPlayers(source, sa.getParam("Chooser"), sa).get(0) : activator; CardCollectionView choices = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), sa.getParam("Choices"), activator, source, sa); if (!choices.isEmpty()) { String title = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : - Localizer.getInstance().getMessage("lblChooseaCard") +" "; - tgtCards = activator.getController().chooseCardsForEffect(choices, sa, title, 1, 1, false, null); + Localizer.getInstance().getMessage("lblChooseaCard") +" "; + tgtCards = chooser.getController().chooseCardsForEffect(choices, sa, title, 1, 1, false, null); } } else { tgtCards = getDefinedCards(sa); } - if (tgtCards == null) { - return; + if (tgtCards !=null & sa.hasParam("ControlledByTarget")) { + tgtCards = CardLists.filterControlledBy(tgtCards, getTargetPlayers(sa)); } // in case source was LKI or still resolving