From 55ef9d5baf89fc50ad378fdbf125c1d03d4cfdca Mon Sep 17 00:00:00 2001 From: Sloth Date: Sun, 28 Apr 2013 14:44:28 +0000 Subject: [PATCH] - Improved SpellPermanent AI. --- .../card/spellability/SpellPermanent.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/forge/card/spellability/SpellPermanent.java b/src/main/java/forge/card/spellability/SpellPermanent.java index 58ce8de30b7..09523b06c49 100644 --- a/src/main/java/forge/card/spellability/SpellPermanent.java +++ b/src/main/java/forge/card/spellability/SpellPermanent.java @@ -104,19 +104,6 @@ public class SpellPermanent extends Spell { } card.setSVar("PayX", Integer.toString(xPay)); } - // Wait for Main2 if possible - if (game.getPhaseHandler().is(PhaseType.MAIN1) - && !ComputerUtil.castPermanentInMain1(ai, this) - && game.getPhaseHandler().isPlayerTurn(ai)) { - return false; - } - // save cards with flash for surprise blocking - if (card.hasKeyword("Flash") - && !card.hasETBTrigger() - && (game.getPhaseHandler().isPlayerTurn(ai) - || game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))) { - return false; - } // Prevent the computer from summoning Ball Lightning type creatures after attacking if (card.hasKeyword("At the beginning of the end step, sacrifice CARDNAME.") && (game.getPhaseHandler().isPlayerTurn(ai.getOpponent()) @@ -129,6 +116,23 @@ public class SpellPermanent extends Spell { && !card.getController().couldCastSorcery(this)) { return false; } + + // Wait for Main2 if possible + if (game.getPhaseHandler().is(PhaseType.MAIN1) + && game.getPhaseHandler().isPlayerTurn(ai) + && ai.getManaPool().totalMana() <= 0 + && !ComputerUtil.castPermanentInMain1(ai, this)) { + return false; + } + // save cards with flash for surprise blocking + if (card.hasKeyword("Flash") + && (ai.isUnlimitedHandSize() || ai.getCardsIn(ZoneType.Hand).size() <= ai.getMaxHandSize()) + && ai.getManaPool().totalMana() <= 0 + && (game.getPhaseHandler().isPlayerTurn(ai) + || game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) + && !card.hasETBTrigger())) { + return false; + } return canPlayFromEffectAI(false, true); } // canPlayAI()