From 7455437fc8137d0c5c12f8ff57c0dfa47fb0a0a3 Mon Sep 17 00:00:00 2001 From: Agetian Date: Wed, 10 Sep 2014 03:49:31 +0000 Subject: [PATCH] - The AI will move equipment off of creatures that are no longer controlled by the AI. --- .../src/main/java/forge/ai/ability/AttachAi.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index c115d7274cf..e113c6c4b2c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -1032,7 +1032,7 @@ public class AttachAi extends SpellAbilityAi { } else if (aic.getProperty(AiProps.MOVE_EQUIPMENT_TO_BETTER_CREATURES).equals("from_useless_only")) { // Do not equip other creatures if the AI profile only allows moving equipment from useless creatures // and the equipped creature is still useful (not non-untapping+tapped and not set to can't attack/block) - if (!isUselessCreature(attachSource.getEquippingCard())) { + if (!isUselessCreature(aiPlayer, attachSource.getEquippingCard())) { return null; } } @@ -1115,7 +1115,7 @@ public class AttachAi extends SpellAbilityAi { } // Consider exceptional cases which break the normal evaluation rules - if (!isUsefulAttachAction(c, sa)) { + if (!isUsefulAttachAction(ai, c, sa)) { return null; } @@ -1308,7 +1308,7 @@ public class AttachAi extends SpellAbilityAi { * @param sa SpellAbility * @return true, if the action is useful (beneficial) in the current minimal context (Card vs. Attach SpellAbility) */ - private static boolean isUsefulAttachAction(Card c, SpellAbility sa) { + private static boolean isUsefulAttachAction(Player ai, Card c, SpellAbility sa) { if (c == null) { return false; } @@ -1321,7 +1321,7 @@ public class AttachAi extends SpellAbilityAi { ArrayList cardTypes = sa.getHostCard().getType(); - if (cardTypes.contains("Equipment") && isUselessCreature(c)) { + if (cardTypes.contains("Equipment") && isUselessCreature(ai, c)) { // useless to equip a creature that can't attack or block. return false; } @@ -1329,13 +1329,14 @@ public class AttachAi extends SpellAbilityAi { return true; } - private static boolean isUselessCreature(Card c) { + private static boolean isUselessCreature(Player ai, Card c) { if (c == null) { return true; } if (c.hasKeyword("CARDNAME can't attack or block.") - || (c.hasKeyword("CARDNAME doesn't untap during your untap step.") && c.isTapped())) { + || (c.hasKeyword("CARDNAME doesn't untap during your untap step.") && c.isTapped()) + || (c.getOwner() == ai && ai.getOpponents().contains(c.getController()))) { return true; }