mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- Added a variant of the Targeting AI SVar.
This commit is contained in:
@@ -22,6 +22,7 @@ import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
import forge.game.ai.ComputerUtilMana;
|
||||
@@ -814,12 +815,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't pump cards that will die.
|
||||
prefList = CardLists.filter(prefList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !c.getSVar("Targeting").equals("Dies");
|
||||
}
|
||||
});
|
||||
prefList = ComputerUtil.getSafeTargets(ai, sa, prefList);
|
||||
|
||||
if (attachSource.isAura() && !attachSource.getName().equals("Daybreak Coronet")) {
|
||||
// TODO For Auras like Rancor, that aren't as likely to lead to
|
||||
|
||||
@@ -722,12 +722,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
List<Card> aiPermanents = CardLists.filterControlledBy(list, ai);
|
||||
|
||||
// Don't blink cards that will die.
|
||||
aiPermanents = CardLists.filter(aiPermanents, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !c.getSVar("Targeting").equals("Dies");
|
||||
}
|
||||
});
|
||||
aiPermanents = ComputerUtil.getSafeTargets(ai, sa, aiPermanents);
|
||||
|
||||
// if it's blink or bounce, try to save my about to die stuff
|
||||
if ((destination.equals(ZoneType.Hand) || (destination.equals(ZoneType.Exile)
|
||||
|
||||
@@ -10,6 +10,7 @@ import forge.CardLists;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.player.Player;
|
||||
import forge.util.MyRandom;
|
||||
@@ -26,12 +27,7 @@ public class FightAi extends SpellAbilityAi {
|
||||
|
||||
List<Card> aiCreatures = ai.getCreaturesInPlay();
|
||||
aiCreatures = CardLists.getTargetableCards(aiCreatures, sa);
|
||||
aiCreatures = CardLists.filter(aiCreatures, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !c.getSVar("Targeting").equals("Dies");
|
||||
}
|
||||
});
|
||||
aiCreatures = ComputerUtil.getSafeTargets(ai, sa, aiCreatures);
|
||||
|
||||
List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay();
|
||||
humCreatures = CardLists.getTargetableCards(humCreatures, sa);
|
||||
|
||||
@@ -14,6 +14,7 @@ import forge.card.cost.Cost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.Game;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.ai.ComputerUtilCost;
|
||||
@@ -215,13 +216,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Don't target cards that will die.
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
System.out.println("Not Protecting");
|
||||
return !c.getSVar("Targeting").equals("Dies");
|
||||
}
|
||||
});
|
||||
list = ComputerUtil.getSafeTargets(ai, sa, list);
|
||||
|
||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
Card t = null;
|
||||
|
||||
@@ -250,12 +250,7 @@ public class PumpAi extends PumpAiBase {
|
||||
|
||||
if (!sa.isCurse()) {
|
||||
// Don't target cards that will die.
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !c.getSVar("Targeting").equals("Dies");
|
||||
}
|
||||
});
|
||||
list = ComputerUtil.getSafeTargets(ai, sa, list);
|
||||
}
|
||||
|
||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
|
||||
@@ -1663,4 +1663,19 @@ public class ComputerUtil {
|
||||
GuiChoose.one("Computer picked: ", new String[]{chosen});
|
||||
return chosen;
|
||||
}
|
||||
|
||||
public static List<Card> getSafeTargets(final Player ai, SpellAbility sa, List<Card> validCards) {
|
||||
List<Card> safeCards = new ArrayList<Card>(validCards);
|
||||
safeCards = CardLists.filter(safeCards, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.getController() == ai) {
|
||||
if (c.getSVar("Targeting").equals("Dies") || c.getSVar("Targeting").equals("Counter"))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return safeCards;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user