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 57d454c00e..f50e64ae59 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 @@ -559,6 +559,41 @@ public class ComputerPlayer> extends PlayerImpl i } } return false; + } + if (target instanceof TargetSpellOrPermanent) { + List targets; + boolean outcomeTargets = true; + if (outcome.isGood()) { + targets = threats(playerId, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets()); + } + else { + targets = threats(opponentId, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets()); + } + if (targets.isEmpty() && target.isRequired()) { + targets = threats(null, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets()); + Collections.reverse(targets); + outcomeTargets = false; + //targets = game.getBattlefield().getActivePermanents(((TargetPermanent)target).getFilter(), playerId, game); + } + for (Permanent permanent: targets) { + if (((TargetPermanent)target).canTarget(playerId, permanent.getId(), source, game)) { + target.addTarget(permanent.getId(), source, game); + if (!outcomeTargets || target.getMaxNumberOfTargets() <= target.getTargets().size()) { + return true; + } + } + } + if (game.getStack().size() > 0) { + Iterator it = game.getStack().iterator(); + while (it.hasNext()) { + StackObject o = it.next(); + if (o instanceof Spell && !source.getId().equals(o.getStackAbility().getId())) { + target.addTarget(o.getId(), source, game); + return true; + } + } + } + return false; } if (target instanceof TargetCardInOpponentsGraveyard) { List cards = new ArrayList<>(); diff --git a/Mage.Sets/src/mage/sets/theros/ChainedToTheRocks.java b/Mage.Sets/src/mage/sets/theros/ChainedToTheRocks.java index 4265166f71..b98dd73e62 100644 --- a/Mage.Sets/src/mage/sets/theros/ChainedToTheRocks.java +++ b/Mage.Sets/src/mage/sets/theros/ChainedToTheRocks.java @@ -32,7 +32,6 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.ExileTargetEffect; @@ -43,7 +42,6 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.TargetController; -import mage.constants.WatcherScope; import mage.constants.Zone; import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterCreaturePermanent; @@ -56,7 +54,6 @@ import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; -import mage.watchers.WatcherImpl; /** * If the land Chained to the Rocks is enchanting stops being a Mountain or another player