From c4d75273f02c4eecf3cc56274561eedc5e1500fc Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 02:49:51 +0000 Subject: [PATCH] - Fixed Karakas AI targeting code. - Removed Corrupt from CardFactory_Creatures and readded it into CardFactory. --- res/main.properties | 2 +- src/forge/CardFactory.java | 75 ++++++++++++++++++++++++++ src/forge/CardFactory_Creatures.java | 79 +--------------------------- src/forge/CardFactory_Lands.java | 31 +++++------ 4 files changed, 93 insertions(+), 94 deletions(-) diff --git a/res/main.properties b/res/main.properties index 596ee639cb6..3920e19a883 100644 --- a/res/main.properties +++ b/res/main.properties @@ -1,6 +1,6 @@ program/mail=mtgerror@yahoo.com program/forum=http://www.slightlymagic.net/forum/viewforum.php?f=26 -program/version=MTG Forge -- official beta: 09/11/02, SVN revision: 90 +program/version=MTG Forge -- official beta: 09/11/02, SVN revision: 92 tokens--file=AllTokens.txt diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 0936add3383..9471be6273b 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -16957,6 +16957,81 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell)); }//*************** END ************ END ************************** + //*************** START *********** START ************************** + if(cardName.equals("Corrupt")) + { + + final SpellAbility spell = new Spell(card) + { + private static final long serialVersionUID = 335838994716307031L; + + Card check; + public boolean canPlayAI() + { + if(AllZone.Human_Life.getLife() <= countSwamps(card)) + return true; + + check = getFlying(); + return check != null; + } + + public int countSwamps(Card c) + { + PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController()); + CardList swamps = new CardList(play.getCards()); + swamps = swamps.getType("Swamp"); + return swamps.size(); + } + + public void chooseTargetAI() + { + if(AllZone.Human_Life.getLife() <= 12) //12? mebbe 15? + { + setTargetPlayer(Constant.Player.Human); + return; + } + + Card c = getFlying(); + if((c == null) || (! check.equals(c))) + throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check); + + setTargetCard(c); + }//chooseTargetAI() + + //uses "damage" variable + Card getFlying() + { + CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); + for(int i = 0; i < flying.size(); i++) + if(flying.get(i).getNetDefense() <= countSwamps(card)) + return flying.get(i); + + return null; + } + + public void resolve() + { + int damage = countSwamps(card); + if(getTargetCard() != null) + { + if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) ) + { + Card c = getTargetCard(); + c.addDamage(damage); + AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage); + } + } + else { + AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage); + AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage); + } + }//resolve() + };//SpellAbility + card.clearSpellAbility(); + card.addSpellAbility(spell); + + spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true)); + }//*************** END ************ END ************************** // Cards with Cycling abilities diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 397ae5799fc..6f1217c3609 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -10553,84 +10553,7 @@ public class CardFactory_Creatures { }//*************** END ************ END ************************** - //*************** START *********** START ************************** - else if(cardName.equals("Corrupt")) - { - - final SpellAbility spell = new Spell(card) - { - private static final long serialVersionUID = 335838994716307031L; - - Card check; - public boolean canPlayAI() - { - if(AllZone.Human_Life.getLife() <= countSwamps(card)) - return true; - - check = getFlying(); - return check != null; - } - - public int countSwamps(Card c) - { - PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController()); - CardList swamps = new CardList(play.getCards()); - swamps = swamps.getType("Swamp"); - return swamps.size(); - } - - public void chooseTargetAI() - { - if(AllZone.Human_Life.getLife() <= 12) //12? mebbe 15? - { - setTargetPlayer(Constant.Player.Human); - return; - } - - Card c = getFlying(); - if((c == null) || (! check.equals(c))) - throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +", Card check is " +check); - - setTargetCard(c); - }//chooseTargetAI() - - //uses "damage" variable - Card getFlying() - { - CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); - for(int i = 0; i < flying.size(); i++) - if(flying.get(i).getNetDefense() <= countSwamps(card)) - return flying.get(i); - - return null; - } - - public void resolve() - { - int damage = countSwamps(card); - if(getTargetCard() != null) - { - if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) ) - { - Card c = getTargetCard(); - c.addDamage(damage); - AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage); - } - } - else { - AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage); - AllZone.GameAction.getPlayerLife(card.getController()).addLife(damage); - } - }//resolve() - };//SpellAbility - card.clearSpellAbility(); - card.addSpellAbility(spell); - - spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell,true)); - }//*************** END ************ END ************************** - - - //*************** START *********** START ************************** + //*************** START *********** START ************************** else if(cardName.equals("Serra Avatar")) { Command leavesPlay = new Command() diff --git a/src/forge/CardFactory_Lands.java b/src/forge/CardFactory_Lands.java index 1af483b2a33..d7ff85ef567 100644 --- a/src/forge/CardFactory_Lands.java +++ b/src/forge/CardFactory_Lands.java @@ -868,22 +868,23 @@ class CardFactory_Lands { final Ability_Tap ability = new Ability_Tap(card, "0") { - private static final long serialVersionUID = -6589125907956046586L; + private static final long serialVersionUID = -6589125907956046586L; - public boolean canPlayAI() - { - CardList list = new CardList(AllZone.Human_Play.getCards()); - list = list.filter(new CardListFilter() - { - public boolean addCard(Card c) { - return c.isCreature() && c.getKeyword().contains("Legendary"); - } - }); - - setTargetCard(CardFactoryUtil.AI_getBestCreature(list, card)); - - return list.size() > 0; - } + public boolean canPlayAI() + { + CardList list = new CardList(AllZone.Human_Play.getCards()); + list = list.filter(new CardListFilter() + { + public boolean addCard(Card c) { + return c.isCreature() && c.getKeyword().contains("Legendary"); + } + }); + + if (list.size() > 0) + setTargetCard(CardFactoryUtil.AI_getBestCreature(list, card)); + + return list.size() > 0; + } public void resolve() {