From fa857b7d38aba655cde10e9a97da326aa367a57f Mon Sep 17 00:00:00 2001 From: excessum Date: Mon, 1 Sep 2014 12:45:14 +0000 Subject: [PATCH] - AI will bounce the attacker to save its blocker(s) instead of bouncing the blocker(s) --- .../java/forge/ai/ability/ChangeZoneAi.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 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 78262d9174d..1238cb96b04 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -727,14 +727,17 @@ public class ChangeZoneAi extends SpellAbilityAi { // Don't blink cards that will die. aiPermanents = ComputerUtil.getSafeTargets(ai, sa, aiPermanents); - // Removal on blocker to save my creature + // Combat bouncing if (tgt.getMinTargets(sa.getHostCard(), sa) <= 1) { if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) { Combat currCombat = game.getCombat(); - for (Card attacker : currCombat.getAttackers()) { + List attackers = currCombat.getAttackers(); + ComputerUtilCard.sortByEvaluateCreature(attackers); + for (Card attacker : attackers) { + List blockers = currCombat.getBlockers(attacker); + // Save my attacker by bouncing a blocker if (attacker.getShield().isEmpty() && ComputerUtilCombat.attackerWouldBeDestroyed(ai, attacker, currCombat) && !currCombat.getBlockers(attacker).isEmpty()) { - List blockers = currCombat.getBlockers(attacker); ComputerUtilCard.sortByEvaluateCreature(blockers); Combat combat = new Combat(ai); combat.addAttacker(attacker, ai.getOpponent()); @@ -751,6 +754,15 @@ public class ChangeZoneAi extends SpellAbilityAi { } } } + // Save my blocker by bouncing the attacker (cannot handle blocking multiple attackers) + if (!attacker.getController().equals(ai) && !blockers.isEmpty()) { + for (Card blocker : blockers) { + if (ComputerUtilCombat.blockerWouldBeDestroyed(ai, blocker, currCombat)) { + sa.getTargets().add(attacker); + return true; + } + } + } } } }