mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
fixed ComputerUtil & PlayerControllerAi: return false if spell cost could not be paid
that does fix Madness for AI
This commit is contained in:
@@ -198,10 +198,10 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// this is used for AI's counterspells
|
||||
public static final void playStack(final SpellAbility sa, final Player ai, final Game game) {
|
||||
public static final boolean playStack(final SpellAbility sa, final Player ai, final Game game) {
|
||||
sa.setActivatingPlayer(ai);
|
||||
if (!ComputerUtilCost.canPayCost(sa, ai))
|
||||
return;
|
||||
return false;
|
||||
|
||||
final Card source = sa.getHostCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
@@ -217,6 +217,7 @@ public class ComputerUtil {
|
||||
game.getStack().add(sa);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final void playSpellAbilityForFree(final Player ai, final SpellAbility sa) {
|
||||
@@ -230,12 +231,12 @@ public class ComputerUtil {
|
||||
ai.getGame().getStack().add(sa);
|
||||
}
|
||||
|
||||
public static final void playSpellAbilityWithoutPayingManaCost(final Player ai, final SpellAbility sa, final Game game) {
|
||||
public static final boolean playSpellAbilityWithoutPayingManaCost(final Player ai, final SpellAbility sa, final Game game) {
|
||||
final SpellAbility newSA = sa.copyWithNoManaCost();
|
||||
newSA.setActivatingPlayer(ai);
|
||||
|
||||
if (!CostPayment.canPayAdditionalCosts(newSA.getPayCosts(), newSA)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card source = newSA.getHostCard();
|
||||
@@ -247,6 +248,7 @@ public class ComputerUtil {
|
||||
pay.payComputerCosts(new AiCostDecision(ai, sa));
|
||||
|
||||
game.getStack().add(newSA);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final void playNoStack(final Player ai, final SpellAbility sa, final Game game) {
|
||||
|
||||
@@ -720,9 +720,9 @@ public class PlayerControllerAi extends PlayerController {
|
||||
Spell spell = (Spell) tgtSA;
|
||||
if (brains.canPlayFromEffectAI(spell, !optional, noManaCost) == AiPlayDecision.WillPlay || !optional) {
|
||||
if (noManaCost) {
|
||||
ComputerUtil.playSpellAbilityWithoutPayingManaCost(player, tgtSA, game);
|
||||
return ComputerUtil.playSpellAbilityWithoutPayingManaCost(player, tgtSA, game);
|
||||
} else {
|
||||
ComputerUtil.playStack(tgtSA, player, game);
|
||||
return ComputerUtil.playStack(tgtSA, player, game);
|
||||
}
|
||||
} else
|
||||
return false; // didn't play spell
|
||||
|
||||
Reference in New Issue
Block a user