* Nicol Bolas, Dragon-God - +1 ability: fixed that opponent can skip exile step, fixed that AI selects wrong cards/permanents;

This commit is contained in:
Oleg Agafonov 2020-01-11 09:28:14 +04:00
parent 144e62e4f5
commit 4f1fb63dda

View file

@ -1,5 +1,6 @@
package mage.cards.n; package mage.cards.n;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
@ -7,6 +8,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
@ -17,16 +19,13 @@ import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCardInHand; 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.LinkedHashSet; import java.util.*;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.cards.Card;
/** /**
* @author TheElk801 * @author TheElk801
@ -141,24 +140,47 @@ class NicolBolasDragonGodPlusOneEffect extends OneShotEffect {
if (opponent == null) { if (opponent == null) {
continue; continue;
} }
if (opponent.getHand().isEmpty()
|| !opponent.chooseUse(outcome, "Exile a card in your hand or a permanent you control?", List<Target> possibleTargetTypes = new ArrayList<>();
null, "Card in hand", "Permanent", source, game)) { // hand
TargetPermanent target = new TargetControlledPermanent(); TargetCardInHand targetHand = new TargetCardInHand();
target.setNotTarget(true); if (!opponent.getHand().isEmpty()) {
target.setTargetController(opponentId); possibleTargetTypes.add(targetHand);
if (opponent.choose(outcome, target, source.getSourceId(), game)) { }
MageObject mageObject = game.getObject(target.getFirstTarget()); // permanent
if (mageObject != null TargetPermanent targetPermanent = new TargetControlledPermanent();
&& mageObject instanceof Permanent) { targetPermanent.setNotTarget(true);
cardsOnBattlefield.add((Card) mageObject); targetPermanent.setTargetController(opponentId);
if (!targetPermanent.possibleTargets(opponentId, game).isEmpty()) {
possibleTargetTypes.add(targetPermanent);
}
// choose target type first, AI must use hand first (benefit)
if (possibleTargetTypes.size() > 1
&& !opponent.chooseUse(Outcome.Benefit, "Exile a card in your hand or a permanent you control?",
null, "Card in hand", "Permanent", source, game)) {
Collections.reverse(possibleTargetTypes); // change order (permanent goes first)
}
// choose target
for (Target target : possibleTargetTypes) {
// hand
if (target.equals(targetHand)) {
if (opponent.choose(Outcome.Exile, opponent.getHand(), targetHand, game)
&& game.getCard(targetHand.getFirstTarget()) != null) {
cards.add(game.getCard(targetHand.getFirstTarget()));
break;
} }
} }
} else { // permanent
TargetCardInHand target = new TargetCardInHand(); if (target.equals(targetPermanent)) {
if (opponent.choose(outcome, opponent.getHand(), target, game) if (opponent.choose(Outcome.Exile, targetPermanent, source.getSourceId(), game)) {
&& game.getCard(target.getFirstTarget()) != null) { MageObject mageObject = game.getObject(targetPermanent.getFirstTarget());
cards.add(game.getCard(target.getFirstTarget())); if (mageObject instanceof Permanent) {
cardsOnBattlefield.add((Card) mageObject);
break;
}
}
} }
} }
} }