From ea04f4c902494bb0c8106bbc3b12901e520851b0 Mon Sep 17 00:00:00 2001 From: Sloth Date: Mon, 29 Apr 2013 21:40:59 +0000 Subject: [PATCH] - Cleanup of canPlayAndPayFor function. --- src/main/java/forge/game/ai/AiController.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/forge/game/ai/AiController.java b/src/main/java/forge/game/ai/AiController.java index aec5bfb03f8..96de04459f9 100644 --- a/src/main/java/forge/game/ai/AiController.java +++ b/src/main/java/forge/game/ai/AiController.java @@ -97,12 +97,12 @@ public class AiController { SpellAbility counter = chooseCounterSpell(getPlayableCounters(cards)); if( counter != null ) return counter; - SpellAbility counterETB = chooseSpellAbilities(this.getPossibleETBCounters(), false); + SpellAbility counterETB = chooseSpellAbilyToPlay(this.getPossibleETBCounters(), false); if( counterETB != null ) return counterETB; } - return chooseSpellAbilities(getSpellAbilities(cards), true); + return chooseSpellAbilyToPlay(getSpellAbilities(cards), true); } /** @@ -442,7 +442,7 @@ public class AiController { * objects. * @return a boolean. */ - private SpellAbility chooseSpellAbilities(final List all, boolean skipCounter) { + private SpellAbility chooseSpellAbilyToPlay(final List all, boolean skipCounter) { if ( all == null || all.isEmpty() ) return null; @@ -467,14 +467,15 @@ public class AiController { // This is for playing spells regularly (no Cascade/Ripple etc.) private boolean canPlayAndPayFor(final SpellAbility sa) { - boolean canPlay = sa.canPlay(); - if (!canPlay) + if (!sa.canPlay()) { return false; + } //System.out.printf("Ai thinks of %s @ %s >>> ", sa, sa.getActivatingPlayer().getGame().getPhaseHandler().debugPrintState()); - boolean aiWouldPlay = sa.canPlayAI(); - boolean canPay = ComputerUtilCost.canPayCost(sa, player); + if (!sa.canPlayAI()) { + return false; + } //System.out.printf("wouldPlay: %s, canPay: %s%n", aiWouldPlay, canPay); - return aiWouldPlay && canPay; + return ComputerUtilCost.canPayCost(sa, player); } // not sure "playing biggest spell" matters?