From 43840198ecfe7d25275dd76e715eca8e1a8be5c6 Mon Sep 17 00:00:00 2001 From: excessum Date: Sat, 8 Oct 2016 12:31:11 +0000 Subject: [PATCH] - Updated PumpAi --- .../main/java/forge/ai/ability/PumpAi.java | 119 ++++++++---------- 1 file changed, 51 insertions(+), 68 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java index 93bc3352603..3cbcc6def76 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java @@ -36,86 +36,69 @@ public class PumpAi extends PumpAiBase { } return false; } - - /* (non-Javadoc) - * @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility) - */ @Override - protected boolean canPlayAI(Player ai, SpellAbility sa) { - final Cost cost = sa.getPayCosts(); + protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final String aiLogic) { + if ("FellTheMighty".equals(aiLogic)) { + CardCollection aiList = ai.getCreaturesInPlay(); + if (aiList.isEmpty()) { + return false; + } + CardLists.sortByPowerAsc(aiList); + if (!sa.canTarget(aiList.get(0))) { + return false; + } + } + return super.checkAiLogic(ai, sa, aiLogic); + } + + @Override + protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, final PhaseHandler ph) { final Game game = ai.getGame(); - final PhaseHandler ph = game.getPhaseHandler(); - final List keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList(); - final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : ""; - final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : ""; - final boolean isFight = "Fight".equals(sa.getParam("AILogic")) || "PowerDmg".equals(sa.getParam("AILogic")); - - if (!ComputerUtilCost.checkLifeCost(ai, cost, sa.getHostCard(), 4, null)) { - return false; - } - - if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard())) { - return false; - } - - if (!ComputerUtilCost.checkCreatureSacrificeCost(ai, cost, sa.getHostCard())) { - return false; - } - - if (!ComputerUtilCost.checkRemoveCounterCost(cost, sa.getHostCard())) { - return false; - } - - if (!ComputerUtilCost.checkTapTypeCost(ai, cost, sa.getHostCard())) { - return false; - } - - if (game.getStack().isEmpty() && hasTapCost(cost, sa.getHostCard())) { - if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) && ph.isPlayerTurn(ai)) { - return false; - } - if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS) && ph.isPlayerTurn(ai.getOpponent())) { - return false; - } - } - - if (sa.hasParam("AILogic")) { - if (sa.getParam("AILogic").equals("Never")) { - return false; + if (game.getStack().isEmpty() && hasTapCost(sa.getPayCosts(), sa.getHostCard())) { + if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) && ph.isPlayerTurn(ai)) { + return false; } - if (sa.getParam("AILogic").equals("FellTheMighty")) { - CardCollection aiList = ai.getCreaturesInPlay(); - if (aiList.isEmpty()) { - return false; - } - CardLists.sortByPowerAsc(aiList); - Card lowest = aiList.get(0); - if (!sa.canTarget(lowest)) { - return false; - } - CardCollection oppList = ai.getOpponent().getCreaturesInPlay(); - oppList = CardLists.filterPower(oppList, lowest.getNetPower()+1); - if (ComputerUtilCard.evaluateCreatureList(oppList) > 200) { - sa.resetTargets(); - sa.getTargets().add(lowest); - return true; - } + if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS) && ph.isPlayerTurn(ai.getOpponent())) { + return false; } } - - if (ComputerUtil.preventRunAwayActivations(sa)) { - return false; - } - - // Phase Restrictions if (game.getStack().isEmpty() && ph.getPhase().isBefore(PhaseType.COMBAT_BEGIN)) { // Instant-speed pumps should not be cast outside of combat when the // stack is empty if (!sa.isCurse() && !SpellAbilityAi.isSorcerySpeed(sa)) { return false; } - } else if (!game.getStack().isEmpty() && !sa.isCurse() && !isFight) { + } + return true; + } + + @Override + protected boolean checkApiLogic(Player ai, SpellAbility sa) { + final Game game = ai.getGame(); + final List keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList(); + final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : ""; + final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : ""; + final boolean isFight = "Fight".equals(sa.getParam("AILogic")) || "PowerDmg".equals(sa.getParam("AILogic")); + + if ("FellTheMighty".equals(sa.getParam("AILogic"))) { + CardCollection aiList = ai.getCreaturesInPlay(); + CardLists.sortByPowerAsc(aiList); + Card lowest = aiList.get(0); + CardCollection oppList = ai.getOpponent().getCreaturesInPlay(); + oppList = CardLists.filterPower(oppList, lowest.getNetPower()+1); + if (ComputerUtilCard.evaluateCreatureList(oppList) > 200) { + sa.resetTargets(); + sa.getTargets().add(lowest); + return true; + } + } + + if (ComputerUtil.preventRunAwayActivations(sa)) { + return false; + } + + if (!game.getStack().isEmpty() && !sa.isCurse() && !isFight) { return ComputerUtilCard.canPumpAgainstRemoval(ai, sa); }