diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 4906e34d6e4..bf4dd6a167b 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -951,7 +951,8 @@ public class ComputerUtil { return true; } - if (card.isCreature() && !card.hasKeyword("Defender") && (card.hasKeyword("Haste") || ComputerUtil.hasACardGivingHaste(ai) || sa.isDash())) { + if (card.isCreature() && !card.hasKeyword("Defender") + && (card.hasKeyword("Haste") || ComputerUtil.hasACardGivingHaste(ai, true) || sa.isDash())) { return true; } @@ -1237,9 +1238,9 @@ public class ComputerUtil { return false; } - public static boolean hasACardGivingHaste(final Player ai) { - final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield)); - + public static boolean hasACardGivingHaste(final Player ai, final boolean checkOpponentCards) { + final CardCollection all = new CardCollection(ai.getCardsIn(Lists.newArrayList(ZoneType.Battlefield, ZoneType.Command))); + // Special for Anger if (!ai.getGame().isCardInPlay("Yixlid Jailer") && !ai.getCardsIn(ZoneType.Graveyard, "Anger").isEmpty() @@ -1305,6 +1306,28 @@ public class ComputerUtil { } } } + + if (checkOpponentCards) { + // Check if the opponents have any cards giving Haste to all creatures on the battlefield + CardCollection opp = new CardCollection(); + opp.addAll(ai.getOpponents().getCardsIn(ZoneType.Battlefield)); + opp.addAll(ai.getOpponents().getCardsIn(ZoneType.Command)); + + for (final Card c : opp) { + for (StaticAbility stAb : c.getStaticAbilities()) { + Map params = stAb.getMapParams(); + if ("Continuous".equals(params.get("Mode")) && params.containsKey("AddKeyword") + && params.get("AddKeyword").contains("Haste")) { + + final ArrayList affected = Lists.newArrayList(params.get("Affected").split(",")); + if (affected.contains("Creature")) { + return true; + } + } + } + } + } + return false; }