1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-27 17:00:20 -09:00

* Fixed a bug that the AI did not handle to target a card in its hand (e.g. Chrome Mox).

This commit is contained in:
LevelX2 2015-10-22 01:00:17 +02:00
parent 1758b62f58
commit ae69986aef
3 changed files with 30 additions and 20 deletions
Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai
Mage.Sets/src/mage/sets/mirrodin
Mage/src/mage/abilities/effects/common

View file

@ -322,9 +322,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
return target.isChosen();
}
if (target instanceof TargetCardInHand) {
if (target instanceof TargetCardInHand
|| (target.getZone().equals(Zone.HAND) && (target instanceof TargetCard))) {
List<Card> cards = new ArrayList<>();
for (UUID cardId : ((TargetCardInHand) target).possibleTargets(sourceId, this.getId(), game)) {
for (UUID cardId : target.possibleTargets(sourceId, this.getId(), game)) {
Card card = game.getCard(cardId);
if (card != null) {
cards.add(card);

View file

@ -29,6 +29,7 @@ package mage.sets.mirrodin;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -52,6 +53,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
import mage.util.CardUtil;
import mage.util.GameLog;
/**
*
@ -82,9 +85,11 @@ public class ChromeMox extends CardImpl {
class ChromeMoxEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("nonartifact, nonland card");
static {
filter.add(Predicates.not(Predicates.or(new CardTypePredicate(CardType.LAND), new CardTypePredicate(CardType.ARTIFACT))));
}
public ChromeMoxEffect() {
super(Outcome.Benefit);
staticText = "exile a nonartifact, nonland card from your hand";
@ -96,21 +101,29 @@ class ChromeMoxEffect extends OneShotEffect {
@java.lang.Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player.getHand().size() > 0) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
TargetCard target = new TargetCard(Zone.HAND, filter);
player.choose(Outcome.Benefit, target, source.getSourceId(), game);
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
card.moveToExile(getId(), "Chrome Mox (Imprint)", source.getSourceId(), game);
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.imprint(card.getId(), game);
}
return true;
target.setNotTarget(true);
Card cardToImprint = null;
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (controller.getHand().size() > 0 && controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
cardToImprint = controller.getHand().get(target.getFirstTarget(), game);
}
if (sourcePermanent != null) {
if (cardToImprint != null) {
controller.moveCardsToExile(cardToImprint, source, game, true, source.getSourceId(), sourceObject.getIdName() + " (Imprint)");
sourcePermanent.imprint(cardToImprint.getId(), game);
sourcePermanent.addInfo("imprint", CardUtil.addToolTipMarkTags("[Imprinted card - " + GameLog.getColoredObjectIdNameForTooltip(cardToImprint) + "]"), game);
} else {
sourcePermanent.addInfo("imprint", CardUtil.addToolTipMarkTags("[Imprinted card - None]"), game);
}
}
return true;
}
return true;
return false;
}
@java.lang.Override
@ -118,12 +131,10 @@ class ChromeMoxEffect extends OneShotEffect {
return new ChromeMoxEffect(this);
}
}
class ChromeMoxManaEffect extends ManaEffect {
ChromeMoxManaEffect() {
super();
staticText = "Add one mana of any of the exiled card's colors to your mana pool";
@ -133,8 +144,6 @@ class ChromeMoxManaEffect extends ManaEffect {
super(effect);
}
@java.lang.Override
public ChromeMoxManaEffect copy() {
return new ChromeMoxManaEffect(this);
@ -202,4 +211,4 @@ class ChromeMoxManaEffect extends ManaEffect {
return null;
}
}
}

View file

@ -84,7 +84,7 @@ public class ChooseModeEffect extends OneShotEffect {
}
if (choice.isChosen()) {
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(sourcePermanent.getLogName()).append(": ").append(controller.getLogName()).append(" has chosen ").append(choice.getChoice()).toString());
game.informPlayers(sourcePermanent.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
}
game.getState().setValue(source.getSourceId() + "_modeChoice", choice.getChoice());
sourcePermanent.addInfo("_modeChoice", "<font color = 'blue'>Chosen mode: " + choice.getChoice() + "</font>", game);