From 8bd2c59f2701a283f569b9ee09b710d75c06ca95 Mon Sep 17 00:00:00 2001 From: Sloth Date: Sat, 14 Feb 2015 20:29:01 +0000 Subject: [PATCH] - Improved AI using Withered Wretch. --- .../java/forge/ai/ability/ChangeZoneAi.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index 9146dd879af..01c0c29cb53 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -842,7 +842,19 @@ public class ChangeZoneAi extends SpellAbilityAi { } } else if (origin.equals(ZoneType.Graveyard)) { - if (destination.equals(ZoneType.Hand)) { + if (destination.equals(ZoneType.Exile) || destination.equals(ZoneType.Library)) { + // Don't use these abilities before main 2 if possible + if (game.getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) + && !sa.hasParam("ActivationPhases") && !ComputerUtil.castSpellInMain1(ai, sa)) { + return false; + } + if ((!game.getPhaseHandler().getNextTurn().equals(ai) + || game.getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN)) + && !sa.hasParam("PlayerTurn") && !SpellAbilityAi.isSorcerySpeed(sa) + && !ComputerUtil.activateForCost(sa, ai)) { + return false; + } + } else if (destination.equals(ZoneType.Hand)) { // only retrieve cards from computer graveyard list = CardLists.filterControlledBy(list, ai); } else if (sa.hasParam("AttachedTo")) { @@ -864,7 +876,7 @@ public class ChangeZoneAi extends SpellAbilityAi { if (origin.equals(ZoneType.Battlefield) && destination.equals(ZoneType.Exile) && (subApi == ApiType.DelayedTrigger || (subApi == ApiType.ChangeZone && subAffected.equals("Remembered"))) - && !(ai.getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS) || sa.isAbility())) { + && !(game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS) || sa.isAbility())) { return false; } @@ -873,8 +885,8 @@ public class ChangeZoneAi extends SpellAbilityAi { // don't rush bouncing stuff when not going to attack if (!sa.isTrigger() && sa.getPayCosts() != null - && ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) - && ai.getGame().getPhaseHandler().isPlayerTurn(ai) + && game.getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) + && game.getPhaseHandler().isPlayerTurn(ai) && ai.getCreaturesInPlay().isEmpty()) { return false; } @@ -893,7 +905,7 @@ public class ChangeZoneAi extends SpellAbilityAi { } // Only care about combatants during combat - if (ai.getGame().getPhaseHandler().inCombat()) { + if (game.getPhaseHandler().inCombat()) { list = CardLists.getValidCards(list, "Card.attacking,Card.blocking", null, null); }