Fix predictThreatenedObjects

This commit is contained in:
tool4EvEr
2021-09-27 22:20:54 +02:00
parent baf1b11785
commit c00732f3bb

View File

@@ -43,6 +43,7 @@ import forge.card.MagicColor;
import forge.game.CardTraitPredicates; import forge.game.CardTraitPredicates;
import forge.game.Game; import forge.game.Game;
import forge.game.GameActionUtil; import forge.game.GameActionUtil;
import forge.game.GameEntity;
import forge.game.GameObject; import forge.game.GameObject;
import forge.game.GameType; import forge.game.GameType;
import forge.game.ability.AbilityKey; import forge.game.ability.AbilityKey;
@@ -1605,10 +1606,10 @@ public class ComputerUtil {
objects = topStack.getTargets(); objects = topStack.getTargets();
final List<GameObject> canBeTargeted = new ArrayList<>(); final List<GameObject> canBeTargeted = new ArrayList<>();
for (Object o : objects) { for (Object o : objects) {
if (o instanceof Card) { if (o instanceof GameEntity) {
final Card c = (Card) o; final GameEntity ge = (GameEntity) o;
if (c.canBeTargetedBy(topStack)) { if (ge.canBeTargetedBy(topStack)) {
canBeTargeted.add(c); canBeTargeted.add(ge);
} }
} }
} }
@@ -1637,7 +1638,6 @@ public class ComputerUtil {
} }
// Consider pump in subabilities, e.g. Bristling Hydra hexproof subability // Consider pump in subabilities, e.g. Bristling Hydra hexproof subability
saviorWithSubs = saviorWithSubs.getSubAbility(); saviorWithSubs = saviorWithSubs.getSubAbility();
} }
if (saviourApi == ApiType.PutCounter || saviourApi == ApiType.PutCounterAll) { if (saviourApi == ApiType.PutCounter || saviourApi == ApiType.PutCounterAll) {
@@ -2441,7 +2441,6 @@ public class ComputerUtil {
return Iterables.getFirst(votes.keySet(), null); return Iterables.getFirst(votes.keySet(), null);
} }
case "FeatherOrQuill": case "FeatherOrQuill":
// try to mill opponent with Quill vote // try to mill opponent with Quill vote
if (opponent && !controller.cantLose()) { if (opponent && !controller.cantLose()) {
int numQuill = votes.get("Quill").size(); int numQuill = votes.get("Quill").size();
@@ -2514,7 +2513,6 @@ public class ComputerUtil {
int scoreNumbers = ComputerUtilCard.evaluateCreature(sourceNumbers) + tokenScore * (numNumbers + 1); int scoreNumbers = ComputerUtilCard.evaluateCreature(sourceNumbers) + tokenScore * (numNumbers + 1);
return (scoreNumbers >= scoreStrength) != opponent ? "Numbers" : "Strength"; return (scoreNumbers >= scoreStrength) != opponent ? "Numbers" : "Strength";
case "SproutOrHarvest": case "SproutOrHarvest":
// lifegain would hurt or has no effect // lifegain would hurt or has no effect
if (opponent) { 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) { 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(); AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
CardCollection targets = new CardCollection(); CardCollection targets = new CardCollection();
for (Card c : options) { for (Card c : options) {