From b79862bcd3ad068ecb4d21ebfe9802943dbfc36d Mon Sep 17 00:00:00 2001 From: Sol Date: Thu, 11 Feb 2016 20:35:26 +0000 Subject: [PATCH] - AttachAI shouldn't assume it targets --- .../main/java/forge/ai/ability/AttachAi.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 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 a641579ecd1..1156ded127c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -659,7 +659,7 @@ public class AttachAi extends SpellAbilityAi { prefList = CardLists.filter(prefList, new Predicate() { @Override public boolean apply(final Card c) { - return ComputerUtilCombat.canAttackNextTurn(c) && c.getNetPower() > 0; + return ComputerUtilCombat.canAttackNextTurn(c) && c.getNetPower() > 0; } }); } @@ -998,7 +998,7 @@ public class AttachAi extends SpellAbilityAi { if (!c.isCreature()) { return true; } - return ComputerUtilCombat.canAttackNextTurn(c) && powerBonus + c.getNetPower() > 0; + return ComputerUtilCombat.canAttackNextTurn(c) && powerBonus + c.getNetPower() > 0; } }); } @@ -1047,16 +1047,20 @@ public class AttachAi extends SpellAbilityAi { return null; } - CardCollection list = CardLists.getValidCards(aiPlayer.getGame().getCardsIn(tgt.getZone()), tgt.getValidTgts(), sa.getActivatingPlayer(), attachSource); - - // TODO If Attaching without casting, don't need to actually target. - // I believe this is the only case where mandatory will be true, so just - // check that when starting that work - // But we shouldn't attach to things with Protection - if (!mandatory) { - list = CardLists.getTargetableCards(list, sa); + CardCollection list = null; + if (tgt == null) { + list = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa); } else { - list = CardLists.filter(list, Predicates.not(CardPredicates.isProtectedFrom(attachSource))); + list = CardLists.getValidCards(aiPlayer.getGame().getCardsIn(tgt.getZone()), tgt.getValidTgts(), sa.getActivatingPlayer(), attachSource); + // TODO If Attaching without casting, don't need to actually target. + // I believe this is the only case where mandatory will be true, so just + // check that when starting that work + // But we shouldn't attach to things with Protection + if (!mandatory) { + list = CardLists.getTargetableCards(list, sa); + } else { + list = CardLists.filter(list, Predicates.not(CardPredicates.isProtectedFrom(attachSource))); + } } if (list.isEmpty()) {