fixed ComputerUtil & PlayerControllerAi: return false if spell cost could not be paid

that does fix Madness for AI
This commit is contained in:
Hanmac
2016-08-02 18:12:10 +00:00
parent 5f1a05dcf5
commit a381163a12
2 changed files with 8 additions and 6 deletions

View File

@@ -198,10 +198,10 @@ public class ComputerUtil {
} }
// this is used for AI's counterspells // 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); sa.setActivatingPlayer(ai);
if (!ComputerUtilCost.canPayCost(sa, ai)) if (!ComputerUtilCost.canPayCost(sa, ai))
return; return false;
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
@@ -217,6 +217,7 @@ public class ComputerUtil {
game.getStack().add(sa); game.getStack().add(sa);
} }
} }
return true;
} }
public static final void playSpellAbilityForFree(final Player ai, final SpellAbility sa) { public static final void playSpellAbilityForFree(final Player ai, final SpellAbility sa) {
@@ -230,12 +231,12 @@ public class ComputerUtil {
ai.getGame().getStack().add(sa); 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(); final SpellAbility newSA = sa.copyWithNoManaCost();
newSA.setActivatingPlayer(ai); newSA.setActivatingPlayer(ai);
if (!CostPayment.canPayAdditionalCosts(newSA.getPayCosts(), newSA)) { if (!CostPayment.canPayAdditionalCosts(newSA.getPayCosts(), newSA)) {
return; return false;
} }
final Card source = newSA.getHostCard(); final Card source = newSA.getHostCard();
@@ -247,6 +248,7 @@ public class ComputerUtil {
pay.payComputerCosts(new AiCostDecision(ai, sa)); pay.payComputerCosts(new AiCostDecision(ai, sa));
game.getStack().add(newSA); game.getStack().add(newSA);
return true;
} }
public static final void playNoStack(final Player ai, final SpellAbility sa, final Game game) { public static final void playNoStack(final Player ai, final SpellAbility sa, final Game game) {

View File

@@ -720,9 +720,9 @@ public class PlayerControllerAi extends PlayerController {
Spell spell = (Spell) tgtSA; Spell spell = (Spell) tgtSA;
if (brains.canPlayFromEffectAI(spell, !optional, noManaCost) == AiPlayDecision.WillPlay || !optional) { if (brains.canPlayFromEffectAI(spell, !optional, noManaCost) == AiPlayDecision.WillPlay || !optional) {
if (noManaCost) { if (noManaCost) {
ComputerUtil.playSpellAbilityWithoutPayingManaCost(player, tgtSA, game); return ComputerUtil.playSpellAbilityWithoutPayingManaCost(player, tgtSA, game);
} else { } else {
ComputerUtil.playStack(tgtSA, player, game); return ComputerUtil.playStack(tgtSA, player, game);
} }
} else } else
return false; // didn't play spell return false; // didn't play spell