mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- 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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user