- AI will bounce the attacker to save its blocker(s) instead of bouncing the blocker(s)

This commit is contained in:
excessum
2014-09-01 12:45:14 +00:00
parent 6a4b140ffe
commit fa857b7d38

View File

@@ -727,14 +727,17 @@ public class ChangeZoneAi extends SpellAbilityAi {
// Don't blink cards that will die. // Don't blink cards that will die.
aiPermanents = ComputerUtil.getSafeTargets(ai, sa, aiPermanents); aiPermanents = ComputerUtil.getSafeTargets(ai, sa, aiPermanents);
// Removal on blocker to save my creature // Combat bouncing
if (tgt.getMinTargets(sa.getHostCard(), sa) <= 1) { if (tgt.getMinTargets(sa.getHostCard(), sa) <= 1) {
if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) { if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
Combat currCombat = game.getCombat(); Combat currCombat = game.getCombat();
for (Card attacker : currCombat.getAttackers()) { List<Card> attackers = currCombat.getAttackers();
ComputerUtilCard.sortByEvaluateCreature(attackers);
for (Card attacker : attackers) {
List<Card> blockers = currCombat.getBlockers(attacker);
// Save my attacker by bouncing a blocker
if (attacker.getShield().isEmpty() && ComputerUtilCombat.attackerWouldBeDestroyed(ai, attacker, currCombat) if (attacker.getShield().isEmpty() && ComputerUtilCombat.attackerWouldBeDestroyed(ai, attacker, currCombat)
&& !currCombat.getBlockers(attacker).isEmpty()) { && !currCombat.getBlockers(attacker).isEmpty()) {
List<Card> blockers = currCombat.getBlockers(attacker);
ComputerUtilCard.sortByEvaluateCreature(blockers); ComputerUtilCard.sortByEvaluateCreature(blockers);
Combat combat = new Combat(ai); Combat combat = new Combat(ai);
combat.addAttacker(attacker, ai.getOpponent()); 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;
}
}
}
} }
} }
} }