From 42416bf73255e37cdb78aeed693f9589996528c8 Mon Sep 17 00:00:00 2001 From: tool4ever Date: Wed, 15 Jan 2025 19:26:41 +0100 Subject: [PATCH] CharmAi: fix duplicated choice (#6776) --- .../src/main/java/forge/ai/ability/CharmAi.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/CharmAi.java b/forge-ai/src/main/java/forge/ai/ability/CharmAi.java index 35522910d2e..bbe10fcd12d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CharmAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CharmAi.java @@ -32,13 +32,14 @@ protected boolean checkApiLogic(Player ai, SpellAbility sa) { } boolean timingRight = sa.isTrigger(); //is there a reason to play the charm now? + boolean choiceForOpp = !ai.equals(sa.getActivatingPlayer()); // Reset the chosen list otherwise it will be locked in forever by earlier calls sa.setChosenList(null); sa.setSubAbility(null); List chosenList; - - if (!ai.equals(sa.getActivatingPlayer())) { + + if (choiceForOpp) { // This branch is for "An Opponent chooses" Charm spells from Alliances // Current just choose the first available spell, which seem generally less disastrous for the AI. chosenList = choices.subList(1, choices.size()); @@ -78,6 +79,11 @@ protected boolean checkApiLogic(Player ai, SpellAbility sa) { // store the choices so they'll get reused sa.setChosenList(chosenList); + + if (choiceForOpp) { + return true; + } + if (sa.isSpell()) { // prebuild chain to improve cost calculation accuracy CharmEffect.chainAbilities(sa, chosenList); @@ -107,9 +113,8 @@ private List chooseOptionsAi(SpellAbility sa, List choic int curPawprintAmount = AbilityUtils.calculateAmount(sub.getHostCard(), sub.getParamOrDefault("Pawprint", "0"), sub); if (pawprintAmount + curPawprintAmount > pawprintLimit) { continue; - } else { - pawprintAmount += curPawprintAmount; } + pawprintAmount += curPawprintAmount; } chosenList.add(sub); if (chosenList.size() == num) {