Skip to content

Commit 42416bf

Browse files
authored
CharmAi: fix duplicated choice (Card-Forge#6776)
1 parent bf2c184 commit 42416bf

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

forge-ai/src/main/java/forge/ai/ability/CharmAi.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ protected boolean checkApiLogic(Player ai, SpellAbility sa) {
3232
}
3333

3434
boolean timingRight = sa.isTrigger(); //is there a reason to play the charm now?
35+
boolean choiceForOpp = !ai.equals(sa.getActivatingPlayer());
3536

3637
// Reset the chosen list otherwise it will be locked in forever by earlier calls
3738
sa.setChosenList(null);
3839
sa.setSubAbility(null);
3940
List<AbilitySub> chosenList;
40-
41-
if (!ai.equals(sa.getActivatingPlayer())) {
41+
42+
if (choiceForOpp) {
4243
// This branch is for "An Opponent chooses" Charm spells from Alliances
4344
// Current just choose the first available spell, which seem generally less disastrous for the AI.
4445
chosenList = choices.subList(1, choices.size());
@@ -78,6 +79,11 @@ protected boolean checkApiLogic(Player ai, SpellAbility sa) {
7879

7980
// store the choices so they'll get reused
8081
sa.setChosenList(chosenList);
82+
83+
if (choiceForOpp) {
84+
return true;
85+
}
86+
8187
if (sa.isSpell()) {
8288
// prebuild chain to improve cost calculation accuracy
8389
CharmEffect.chainAbilities(sa, chosenList);
@@ -107,9 +113,8 @@ private List<AbilitySub> chooseOptionsAi(SpellAbility sa, List<AbilitySub> choic
107113
int curPawprintAmount = AbilityUtils.calculateAmount(sub.getHostCard(), sub.getParamOrDefault("Pawprint", "0"), sub);
108114
if (pawprintAmount + curPawprintAmount > pawprintLimit) {
109115
continue;
110-
} else {
111-
pawprintAmount += curPawprintAmount;
112116
}
117+
pawprintAmount += curPawprintAmount;
113118
}
114119
chosenList.add(sub);
115120
if (chosenList.size() == num) {

0 commit comments

Comments
 (0)