From f26b46702d43ec840f7ef63ee7617ee889e9f7cf Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 23 Apr 2019 15:24:31 -0500 Subject: [PATCH] - Fixed #5744 --- .../src/mage/cards/n/NicolBolasDragonGod.java | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/cards/n/NicolBolasDragonGod.java b/Mage.Sets/src/mage/cards/n/NicolBolasDragonGod.java index 3e1ef13549..5c6e26462c 100644 --- a/Mage.Sets/src/mage/cards/n/NicolBolasDragonGod.java +++ b/Mage.Sets/src/mage/cards/n/NicolBolasDragonGod.java @@ -9,8 +9,6 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; import mage.constants.*; import mage.filter.FilterPermanent; import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent; @@ -25,9 +23,11 @@ import mage.target.common.TargetCardInHand; import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetCreatureOrPlaneswalker; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import java.util.UUID; +import mage.MageObject; +import mage.cards.Card; /** * @author TheElk801 @@ -111,7 +111,8 @@ class NicolBolasDragonGodPlusOneEffect extends OneShotEffect { NicolBolasDragonGodPlusOneEffect() { super(Outcome.Benefit); - staticText = "You draw a card. Each opponent exiles a card from their hand or a permanent they control."; + staticText = "You draw a card. Each opponent exiles a card from their " + + "hand or a permanent they control."; } private NicolBolasDragonGodPlusOneEffect(final NicolBolasDragonGodPlusOneEffect effect) { @@ -125,13 +126,14 @@ class NicolBolasDragonGodPlusOneEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { + Boolean applied = false; Player player = game.getPlayer(source.getControllerId()); if (player == null) { return false; } player.drawCards(1, game); - Set perms = new HashSet(); - Cards cards = new CardsImpl(); + Set cardsOnBattlefield = new LinkedHashSet<>(); + Set cards = new LinkedHashSet<>(); for (UUID opponentId : game.getState().getPlayersInRange(player.getId(), game)) { if (!player.hasOpponent(opponentId, game)) { continue; @@ -140,24 +142,38 @@ class NicolBolasDragonGodPlusOneEffect extends OneShotEffect { if (opponent == null) { continue; } - if (opponent.getHand().isEmpty() || - !opponent.chooseUse(outcome, "Exile a card in your hand or a permanent you control?", + if (opponent.getHand().isEmpty() + || !opponent.chooseUse(outcome, "Exile a card in your hand or a permanent you control?", null, "Card in hand", "Permanent", source, game)) { TargetPermanent target = new TargetControlledPermanent(); target.setNotTarget(true); target.setTargetController(opponentId); if (opponent.choose(outcome, target, source.getSourceId(), game)) { - perms.add(target.getFirstTarget()); + MageObject mageObject = game.getObject(target.getFirstTarget()); + if (mageObject != null + && mageObject instanceof Permanent) { + cardsOnBattlefield.add((Card) mageObject); + } } } else { TargetCardInHand target = new TargetCardInHand(); - if (opponent.choose(outcome, opponent.getHand(), target, game)) { - cards.add(target.getFirstTarget()); + if (opponent.choose(outcome, opponent.getHand(), target, game) + && game.getCard(target.getFirstTarget()) != null) { + cards.add(game.getCard(target.getFirstTarget())); } } } - cards.addAll(perms); - return player.moveCards(cards, Zone.EXILED, source, game); + cards.addAll(cardsOnBattlefield); + for (Card card : cards) { + if (card != null) { + Player owner = game.getPlayer(card.getOwnerId()); + if (owner != null + && owner.moveCards(card, Zone.EXILED, source, game)) { + applied = true; + } + } + } + return applied; } } @@ -196,4 +212,4 @@ class NicolBolasDragonGodMinus8Effect extends OneShotEffect { } return true; } -} \ No newline at end of file +}