From c00732f3bb07327e3af23a4af1283279b812b877 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Mon, 27 Sep 2021 22:20:54 +0200 Subject: [PATCH] Fix predictThreatenedObjects --- forge-ai/src/main/java/forge/ai/ComputerUtil.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 5fea7a43a4f..46566e4228f 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -43,6 +43,7 @@ import forge.card.MagicColor; import forge.game.CardTraitPredicates; import forge.game.Game; import forge.game.GameActionUtil; +import forge.game.GameEntity; import forge.game.GameObject; import forge.game.GameType; import forge.game.ability.AbilityKey; @@ -1605,10 +1606,10 @@ public class ComputerUtil { objects = topStack.getTargets(); final List canBeTargeted = new ArrayList<>(); for (Object o : objects) { - if (o instanceof Card) { - final Card c = (Card) o; - if (c.canBeTargetedBy(topStack)) { - canBeTargeted.add(c); + if (o instanceof GameEntity) { + final GameEntity ge = (GameEntity) o; + if (ge.canBeTargetedBy(topStack)) { + canBeTargeted.add(ge); } } } @@ -1637,7 +1638,6 @@ public class ComputerUtil { } // Consider pump in subabilities, e.g. Bristling Hydra hexproof subability saviorWithSubs = saviorWithSubs.getSubAbility(); - } if (saviourApi == ApiType.PutCounter || saviourApi == ApiType.PutCounterAll) { @@ -2441,7 +2441,6 @@ public class ComputerUtil { return Iterables.getFirst(votes.keySet(), null); } case "FeatherOrQuill": - // try to mill opponent with Quill vote if (opponent && !controller.cantLose()) { int numQuill = votes.get("Quill").size(); @@ -2514,7 +2513,6 @@ public class ComputerUtil { int scoreNumbers = ComputerUtilCard.evaluateCreature(sourceNumbers) + tokenScore * (numNumbers + 1); return (scoreNumbers >= scoreStrength) != opponent ? "Numbers" : "Strength"; - case "SproutOrHarvest": // lifegain would hurt or has no effect if (opponent) { @@ -2893,7 +2891,7 @@ public class ComputerUtil { } public static boolean targetPlayableSpellCard(final Player ai, CardCollection options, final SpellAbility sa, final boolean withoutPayingManaCost, boolean mandatory) { - // determine and target a card with a SA that the AI can afford and will play + // determine and target a card with a SA that the AI can afford and will play AiController aic = ((PlayerControllerAi) ai.getController()).getAi(); CardCollection targets = new CardCollection(); for (Card c : options) {