From 94d3c70d4442e0fb9921783186505ed0d0f9a8c5 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Mon, 1 Aug 2022 21:15:45 +0200 Subject: [PATCH] AI fix --- .../src/main/java/forge/ai/ComputerUtilCost.java | 2 +- .../main/java/forge/ai/ability/CountersPutAi.java | 5 +++-- forge-ai/src/main/java/forge/ai/ability/TokenAi.java | 12 ++++++------ .../src/main/java/forge/game/keyword/Trample.java | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index 2f39a64fbf5..1c1b88a4313 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -875,7 +875,7 @@ public class ComputerUtilCost { } } - val = ObjectUtils.min(val, abCost.getMaxForNonManaX(root, ai, false)); + val = ObjectUtils.min(val, abCost.getMaxForNonManaX(root, ai, effect)); if (val != null && val > 0) { // filter cost parts for preferences, don't choose X > than possible preferences diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index 667aee15d71..30e5a8a8112 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -768,8 +768,9 @@ public class CountersPutAi extends CountersAi { list = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa); if (amountStr.equals("X") - && root.getXManaCostPaid() != null /* SubAbility on something that already had set PayX, e.g. Endless One ETB counters */ - && sa.hasParam(amountStr) && sa.getSVar(amountStr).equals("Count$xPaid")) { + && root.getXManaCostPaid() == null + && source.getXManaCostPaid() == 0 /* SubAbility on something that already had set PayX, e.g. Endless One ETB counters */ + && sa.hasSVar(amountStr) && sa.getSVar(amountStr).equals("Count$xPaid")) { // detect if there's more than one X in the cost (Hangarback Walker, Walking Ballista, etc.) SpellAbility testSa = sa; diff --git a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java index 16af0fbd221..83e73ffa0a1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java @@ -273,6 +273,12 @@ public class TokenAi extends SpellAbilityAi { } } + if (mandatory) { + // Necessary because the AI goes into this method twice, first to set up targets (with mandatory=true) + // and then the second time to confirm the trigger (where mandatory may be set to false). + return true; + } + Card actualToken = spawnToken(ai, sa); String tokenPower = sa.getParamOrDefault("TokenPower", actualToken.getBasePowerString()); String tokenToughness = sa.getParamOrDefault("TokenToughness", actualToken.getBaseToughnessString()); @@ -293,12 +299,6 @@ public class TokenAi extends SpellAbilityAi { } } - if (mandatory) { - // Necessary because the AI goes into this method twice, first to set up targets (with mandatory=true) - // and then the second time to confirm the trigger (where mandatory may be set to false). - return true; - } - if ("OnlyOnAlliedAttack".equals(sa.getParam("AILogic"))) { Combat combat = ai.getGame().getCombat(); return combat != null && combat.getAttackingPlayer() != null diff --git a/forge-game/src/main/java/forge/game/keyword/Trample.java b/forge-game/src/main/java/forge/game/keyword/Trample.java index 1d8eb7a4564..b2c94c5a818 100644 --- a/forge-game/src/main/java/forge/game/keyword/Trample.java +++ b/forge-game/src/main/java/forge/game/keyword/Trample.java @@ -2,7 +2,7 @@ package forge.game.keyword; import java.util.Collection; -public class Trample extends KeywordInstance { +public class Trample extends KeywordInstance { private String type = ""; @Override