This commit is contained in:
Jeff 2019-04-23 15:24:31 -05:00
parent ef3689a225
commit f26b46702d

View file

@ -9,8 +9,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.*; import mage.constants.*;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent; import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
@ -25,9 +23,11 @@ import mage.target.common.TargetCardInHand;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreatureOrPlaneswalker; import mage.target.common.TargetCreatureOrPlaneswalker;
import java.util.HashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.cards.Card;
/** /**
* @author TheElk801 * @author TheElk801
@ -111,7 +111,8 @@ class NicolBolasDragonGodPlusOneEffect extends OneShotEffect {
NicolBolasDragonGodPlusOneEffect() { NicolBolasDragonGodPlusOneEffect() {
super(Outcome.Benefit); 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) { private NicolBolasDragonGodPlusOneEffect(final NicolBolasDragonGodPlusOneEffect effect) {
@ -125,13 +126,14 @@ class NicolBolasDragonGodPlusOneEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Boolean applied = false;
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player == null) { if (player == null) {
return false; return false;
} }
player.drawCards(1, game); player.drawCards(1, game);
Set<UUID> perms = new HashSet(); Set<Card> cardsOnBattlefield = new LinkedHashSet<>();
Cards cards = new CardsImpl(); Set<Card> cards = new LinkedHashSet<>();
for (UUID opponentId : game.getState().getPlayersInRange(player.getId(), game)) { for (UUID opponentId : game.getState().getPlayersInRange(player.getId(), game)) {
if (!player.hasOpponent(opponentId, game)) { if (!player.hasOpponent(opponentId, game)) {
continue; continue;
@ -140,24 +142,38 @@ class NicolBolasDragonGodPlusOneEffect extends OneShotEffect {
if (opponent == null) { if (opponent == null) {
continue; continue;
} }
if (opponent.getHand().isEmpty() || if (opponent.getHand().isEmpty()
!opponent.chooseUse(outcome, "Exile a card in your hand or a permanent you control?", || !opponent.chooseUse(outcome, "Exile a card in your hand or a permanent you control?",
null, "Card in hand", "Permanent", source, game)) { null, "Card in hand", "Permanent", source, game)) {
TargetPermanent target = new TargetControlledPermanent(); TargetPermanent target = new TargetControlledPermanent();
target.setNotTarget(true); target.setNotTarget(true);
target.setTargetController(opponentId); target.setTargetController(opponentId);
if (opponent.choose(outcome, target, source.getSourceId(), game)) { 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 { } else {
TargetCardInHand target = new TargetCardInHand(); TargetCardInHand target = new TargetCardInHand();
if (opponent.choose(outcome, opponent.getHand(), target, game)) { if (opponent.choose(outcome, opponent.getHand(), target, game)
cards.add(target.getFirstTarget()); && game.getCard(target.getFirstTarget()) != null) {
cards.add(game.getCard(target.getFirstTarget()));
} }
} }
} }
cards.addAll(perms); cards.addAll(cardsOnBattlefield);
return player.moveCards(cards, Zone.EXILED, source, game); 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; return true;
} }
} }