- Improved ChangeTargetsAi for cases when two or more of the same cards with retarget ability are present on the battlefield (e.g. 2x Spellskite), the AI will no longer retarget the spell infinitely to different copies.

This commit is contained in:
Agetian
2017-06-03 15:55:10 +00:00
parent 91f980c6ab
commit 8d93ca9fbc

View File

@@ -6,6 +6,7 @@ import forge.ai.ComputerUtilMana;
import forge.ai.SpellAbilityAi;
import forge.card.mana.ManaCost;
import forge.game.Game;
import forge.game.card.Card;
import forge.game.mana.ManaCostBeingPaid;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
@@ -50,6 +51,14 @@ public class ChangeTargetsAi extends SpellAbilityAi {
return false;
}
for (Card tgt : topSa.getTargets().getTargetCards()) {
// We are already targeting at least one card with the same name (e.g. in presence of 2+ Spellskites),
// no need to retarget again to another one
if (ComputerUtilAbility.getAbilitySourceName(sa).equals(tgt.getName()) && tgt.getController().equals(aiPlayer)) {
return false;
}
}
if (topSa.getHostCard() != null && !topSa.getHostCard().getController().isOpponentOf(aiPlayer)) {
// make sure not to redirect our own abilities
return false;