diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index c27669fe8ba..89fdf85963d 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -321,7 +321,7 @@ public class AiController { if (cons != null) { String pres = cons.getIsPresent(); if (pres != null && pres.matches("Card\\.(Strictly)?Self")) { - cons.setIsPresent(null); + cons.setIsPresent(null); } } @@ -329,6 +329,10 @@ public class AiController { // These checks only work if the Executing SpellAbility is an Ability_Sub. if (exSA instanceof AbilitySub && !doTrigger(exSA, false)) { // AI would not run this trigger if given the chance + if (api == null && card.isCreature() && exSA.usesTargeting() && !exSA.getTargetRestrictions().hasCandidates(exSA) && ComputerUtil.aiLifeInDanger(activatingPlayer, true, 0)) { + // trigger will not run due to lack of targets and we desperately need a creature + continue; + } return false; } } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 87e20e84099..7976398a194 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -3015,6 +3015,7 @@ public class ComputerUtil { // call this to determine if it's safe to use a life payment spell // or trigger "emergency" strategies such as holding mana for Spike Weaver of Counterspell. public static boolean aiLifeInDanger(Player ai, boolean serious, int payment) { + // TODO should also consider them as teams for (Player opponent: ai.getOpponents()) { // test whether the human can kill the ai next turn Combat combat = new Combat(opponent); @@ -3035,10 +3036,10 @@ public class ComputerUtil { // examples : Black Vise, The Rack, known direct damage spells in enemy hand, etc // If added, might need a parameter to define whether we want to check all threats or combat threats. - if ((serious) && (ComputerUtilCombat.lifeInSeriousDanger(ai, combat, payment))) { + if (serious && ComputerUtilCombat.lifeInSeriousDanger(ai, combat, payment)) { return true; } - if ((!serious) && (ComputerUtilCombat.lifeInDanger(ai, combat, payment))) { + if (!serious && ComputerUtilCombat.lifeInDanger(ai, combat, payment)) { return true; } } diff --git a/forge-game/src/main/java/forge/game/cost/Cost.java b/forge-game/src/main/java/forge/game/cost/Cost.java index f0d7d5e69b6..ab62db3a7d3 100644 --- a/forge-game/src/main/java/forge/game/cost/Cost.java +++ b/forge-game/src/main/java/forge/game/cost/Cost.java @@ -94,7 +94,6 @@ public class Cost implements Serializable { return true; } - @SuppressWarnings("unchecked") public T getCostPartByType(Class costType) { for (CostPart p : getCostParts()) {