From 0330f9c34d65e8c98f4ddcdba5de77a81322d21b Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 03:53:47 +0000 Subject: [PATCH] - AI should not try to cast destruction spells that use the spDestroyTgt keyword targeting indestructible permanents anymore. --- src/forge/CardFactory.java | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 5b08dc2d978..efd9dc9d957 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -1629,6 +1629,14 @@ public class CardFactory implements NewConstants { CardList results = new CardList(); CardList choices = getTargets(); + choices = choices.filter(new CardListFilter(){ + public boolean addCard(Card c) + { + return !c.getKeyword().contains("Indestructible"); + } + }); + + if(choices.size() > 0) { for(int i = 0; i < Tgts.length; i++) { if(Tgts[i].equals("Artifact")) { @@ -6805,7 +6813,27 @@ public class CardFactory implements NewConstants { @Override public boolean canPlayAI() { - return AllZone.Computer_Life.getLife() > 3; + if (AllZone.Computer_Life.getLife() <= 3) + return false; + + if (AllZone.Human_Life.getLife() <= 3) + return true; + + CardListFilter filter = new CardListFilter(){ + public boolean addCard(Card c) + { + return c.isCreature() && CardFactoryUtil.canDamage(card, c) && (c.getNetDefense() - c.getDamage())< 4; + } + }; + + CardList humCreats = new CardList(AllZone.Human_Play.getCards()); + humCreats = humCreats.filter(filter); + + CardList compCreats = new CardList(AllZone.Computer_Play.getCards()); + compCreats = compCreats.filter(filter); + + return humCreats.size() > compCreats.size(); + } @Override