diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index ad00bc9c9c8..52cacd0283d 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -291,6 +291,12 @@ public class ComputerUtilMana { 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) { // 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")) @@ -443,7 +449,6 @@ public class ComputerUtilMana { manaProduced = manaProduced.replace(s, color); } } else if (saMana.hasParam("ReplaceColor")) { - // replace color String color = saMana.getParam("ReplaceColor"); if ("Chosen".equals(color)) { if (card.hasChosenColor()) { @@ -735,7 +740,8 @@ public class ComputerUtilMana { if (saPayment != null && ComputerUtilCost.isSacrificeSelfCost(saPayment.getPayCosts())) { 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; } } @@ -1496,7 +1502,7 @@ public class ComputerUtilMana { } if (!cost.isReusuableResource()) { - for(CostPart part : cost.getCostParts()) { + for (CostPart part : cost.getCostParts()) { if (part instanceof CostSacrifice && !part.payCostFromSource()) { unpreferredCost = true; } @@ -1587,10 +1593,8 @@ public class ComputerUtilMana { // don't use abilities with dangerous drawbacks AbilitySub sub = m.getSubAbility(); - if (sub != null) { - if (!SpellApiToAi.Converter.get(sub).chkDrawbackWithSubs(ai, sub).willingToPlay()) { - continue; - } + if (sub != null && !SpellApiToAi.Converter.get(sub).chkDrawbackWithSubs(ai, sub).willingToPlay()) { + continue; } manaMap.get(ManaAtom.GENERIC).add(m); // add to generic source list diff --git a/forge-game/src/main/java/forge/game/ability/effects/ManaEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ManaEffect.java index 49bff555a0f..00092734f13 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ManaEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ManaEffect.java @@ -271,10 +271,11 @@ public class ManaEffect extends SpellAbilityEffect { producedMana.append(abMana.produceMana(mana, p, sa)); } - abMana.tapsForMana(sa.getRootAbility(), producedMana.toString()); - // Only clear express choice after mana has been produced abMana.clearExpressChoice(); + + abMana.tapsForMana(sa.getRootAbility(), producedMana.toString()); + if (sa.isKeyword(Keyword.FIREBENDING)) { activator.triggerElementalBend(TriggerType.Firebend); } diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index aadea4b5274..92d94c496df 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -354,7 +354,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit public int totalAmountOfManaGenerated(SpellAbility saPaidFor, boolean multiply) { int result = 0; AbilityManaPart mp = getManaPart(); - if (mp != null && metConditions() && mp.meetsManaRestrictions(saPaidFor)) { + if (mp != null && mp.meetsManaRestrictions(saPaidFor)) { result += amountOfManaGenerated(multiply); } result += subAbility != null ? subAbility.totalAmountOfManaGenerated(saPaidFor, multiply) : 0;