From a4c2e51ab32f2e7f9ab3b094b02f13decc225cda Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 13 Feb 2018 10:33:33 +0100 Subject: [PATCH] * Added some missing AI target logic. --- .../java/mage/player/ai/ComputerPlayer.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index e8b5168713..472036cc24 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -52,6 +52,7 @@ import mage.cards.repository.CardRepository; import mage.choices.Choice; import mage.choices.ChoiceColor; import mage.constants.*; +import mage.counters.CounterType; import mage.filter.FilterPermanent; import mage.filter.StaticFilters; import mage.filter.common.*; @@ -809,7 +810,54 @@ public class ComputerPlayer extends PlayerImpl implements Player { target.addTarget(opponentId, target.getAmountRemaining(), source, game); return true; } + return false; } + if (target.getOriginalTarget() instanceof TargetCreatureOrPlaneswalkerAmount) { + List targets; + if (outcome.isGood()) { + targets = threats(playerId, source.getSourceId(), StaticFilters.FILTER_PERMANENT_CREATURE, game, target.getTargets()); + } else { + targets = threats(opponentId, source.getSourceId(), StaticFilters.FILTER_PERMANENT_CREATURE, game, target.getTargets()); + } + for (Permanent permanent : targets) { + if (target.canTarget(getId(), permanent.getId(), source, game)) { + if (permanent.getToughness().getValue() <= target.getAmountRemaining()) { + target.addTarget(permanent.getId(), permanent.getToughness().getValue(), source, game); + return true; + } + } + } + if (target.getFilter() instanceof FilterPermanent) { + targets = threats(null, source.getSourceId(), (FilterPermanent) target.getFilter(), game, target.getTargets()); + Permanent possibleTarget = null; + for (Permanent permanent : targets) { + if (target.canTarget(getId(), permanent.getId(), source, game)) { + if (permanent.isCreature()) { + if (permanent.getToughness().getValue() <= target.getAmountRemaining()) { + target.addTarget(permanent.getId(), permanent.getToughness().getValue(), source, game); + return true; + } else { + possibleTarget = permanent; + } + } else if (permanent.isPlaneswalker()) { + int loy = permanent.getCounters(game).getCount(CounterType.LOYALTY); + if (loy <= target.getAmountRemaining()) { + target.addTarget(permanent.getId(), loy, source, game); + return true; + } else { + possibleTarget = permanent; + } + + } + } + } + if (possibleTarget != null) { + target.addTarget(possibleTarget.getId(), target.getAmountRemaining(), source, game); + return true; + } + } + } + log.warn("No proper AI target handling: " + target.getClass().getName()); return false; }