Fix AI sometimes tapping mana sources for 0 (#8659)

This commit is contained in:
tool4ever
2025-09-06 16:18:36 +02:00
committed by GitHub
parent 64e3193a80
commit 1671a3298e
3 changed files with 15 additions and 10 deletions

View File

@@ -291,6 +291,12 @@ public class ComputerUtilMana {
continue; continue;
} }
int amount = ma.hasParam("Amount") ? AbilityUtils.calculateAmount(ma.getHostCard(), ma.getParam("Amount"), ma) : 1;
if (amount <= 0) {
// wrong gamestate for variable amount
continue;
}
if (sa.getApi() == ApiType.Animate) { if (sa.getApi() == ApiType.Animate) {
// For abilities like Genju of the Cedars, make sure that we're not activating the aura ability by tapping the enchanted card for mana // For abilities like Genju of the Cedars, make sure that we're not activating the aura ability by tapping the enchanted card for mana
if (saHost.isAura() && "Enchanted".equals(sa.getParam("Defined")) if (saHost.isAura() && "Enchanted".equals(sa.getParam("Defined"))
@@ -443,7 +449,6 @@ public class ComputerUtilMana {
manaProduced = manaProduced.replace(s, color); manaProduced = manaProduced.replace(s, color);
} }
} else if (saMana.hasParam("ReplaceColor")) { } else if (saMana.hasParam("ReplaceColor")) {
// replace color
String color = saMana.getParam("ReplaceColor"); String color = saMana.getParam("ReplaceColor");
if ("Chosen".equals(color)) { if ("Chosen".equals(color)) {
if (card.hasChosenColor()) { if (card.hasChosenColor()) {
@@ -735,7 +740,8 @@ public class ComputerUtilMana {
if (saPayment != null && ComputerUtilCost.isSacrificeSelfCost(saPayment.getPayCosts())) { if (saPayment != null && ComputerUtilCost.isSacrificeSelfCost(saPayment.getPayCosts())) {
if (sa.getTargets() != null && sa.getTargets().contains(saPayment.getHostCard())) { if (sa.getTargets() != null && sa.getTargets().contains(saPayment.getHostCard())) {
saExcludeList.add(saPayment); // not a good idea to sac a card that you're targeting with the SA you're paying for // not a good idea to sac a card that you're targeting with the SA you're paying for
saExcludeList.add(saPayment);
continue; continue;
} }
} }
@@ -1587,11 +1593,9 @@ public class ComputerUtilMana {
// don't use abilities with dangerous drawbacks // don't use abilities with dangerous drawbacks
AbilitySub sub = m.getSubAbility(); AbilitySub sub = m.getSubAbility();
if (sub != null) { if (sub != null && !SpellApiToAi.Converter.get(sub).chkDrawbackWithSubs(ai, sub).willingToPlay()) {
if (!SpellApiToAi.Converter.get(sub).chkDrawbackWithSubs(ai, sub).willingToPlay()) {
continue; continue;
} }
}
manaMap.get(ManaAtom.GENERIC).add(m); // add to generic source list manaMap.get(ManaAtom.GENERIC).add(m); // add to generic source list

View File

@@ -271,10 +271,11 @@ public class ManaEffect extends SpellAbilityEffect {
producedMana.append(abMana.produceMana(mana, p, sa)); producedMana.append(abMana.produceMana(mana, p, sa));
} }
abMana.tapsForMana(sa.getRootAbility(), producedMana.toString());
// Only clear express choice after mana has been produced // Only clear express choice after mana has been produced
abMana.clearExpressChoice(); abMana.clearExpressChoice();
abMana.tapsForMana(sa.getRootAbility(), producedMana.toString());
if (sa.isKeyword(Keyword.FIREBENDING)) { if (sa.isKeyword(Keyword.FIREBENDING)) {
activator.triggerElementalBend(TriggerType.Firebend); activator.triggerElementalBend(TriggerType.Firebend);
} }

View File

@@ -354,7 +354,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
public int totalAmountOfManaGenerated(SpellAbility saPaidFor, boolean multiply) { public int totalAmountOfManaGenerated(SpellAbility saPaidFor, boolean multiply) {
int result = 0; int result = 0;
AbilityManaPart mp = getManaPart(); AbilityManaPart mp = getManaPart();
if (mp != null && metConditions() && mp.meetsManaRestrictions(saPaidFor)) { if (mp != null && mp.meetsManaRestrictions(saPaidFor)) {
result += amountOfManaGenerated(multiply); result += amountOfManaGenerated(multiply);
} }
result += subAbility != null ? subAbility.totalAmountOfManaGenerated(saPaidFor, multiply) : 0; result += subAbility != null ? subAbility.totalAmountOfManaGenerated(saPaidFor, multiply) : 0;