From 6a30a45cd56a5f83d49c5f0699f3c0ba3fe0990a Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 08:06:27 +0000 Subject: [PATCH] - Moved Vanishing to postFactoryKeywords. This removes the need for it to be in each CardFactory file. - Removed unneeded Vanishing code blocks. - Updated Aven Riftwatcher and Calciderm to use Vanishing. --- res/cardsfolder/aven_riftwatcher.txt | 3 +- res/cardsfolder/calciderm.txt | 3 +- src/forge/CardFactory.java | 29 ++++++++-------- src/forge/CardFactory_Auras.java | 22 ------------ src/forge/CardFactory_Creatures.java | 51 +--------------------------- src/forge/GameActionUtil.java | 36 -------------------- 6 files changed, 19 insertions(+), 125 deletions(-) diff --git a/res/cardsfolder/aven_riftwatcher.txt b/res/cardsfolder/aven_riftwatcher.txt index bad8e3f7e1b..d3a0f2b2668 100644 --- a/res/cardsfolder/aven_riftwatcher.txt +++ b/res/cardsfolder/aven_riftwatcher.txt @@ -1,7 +1,8 @@ Name:Aven Riftwatcher ManaCost:2 W Types:Creature Bird Rebel Soldier -Text:Vanishing 3. When Aven Riftwatcher comes into play or leaves play, you gain 2 life. +Text:When Aven Riftwatcher comes into play or leaves play, you gain 2 life. +K:Vanishing:3 PT:2/3 K:Flying SVar:Rarity:Common diff --git a/res/cardsfolder/calciderm.txt b/res/cardsfolder/calciderm.txt index d58015ec1e1..4ed77254da7 100644 --- a/res/cardsfolder/calciderm.txt +++ b/res/cardsfolder/calciderm.txt @@ -1,7 +1,8 @@ Name:Calciderm ManaCost:2 W W Types:Creature Beast -Text:Vanishing 4 +Text:no text +K:Vanishing:4 PT:5/5 K:Shroud SVar:Rarity:Uncommon diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index f4c5dfac35d..f097c3cf7d5 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -10270,21 +10270,6 @@ public class CardFactory implements NewConstants { } }//Soulshift - if(hasKeyword(card, "Vanishing") != -1) { - int n = hasKeyword(card, "Vanishing"); - if(n != -1) { - String parse = card.getKeyword().get(n).toString(); - card.removeIntrinsicKeyword(parse); - - String k[] = parse.split(":"); - final int power = Integer.parseInt(k[1]); - - - card.addComesIntoPlayCommand(CardFactoryUtil.vanishing(card, power)); - card.addSpellAbility(CardFactoryUtil.vanish_desc(card, power)); - } - }//Vanishing - if(hasKeyword(card, "Echo") != -1) { int n = hasKeyword(card, "Echo"); if(n != -1) { @@ -10434,6 +10419,20 @@ public class CardFactory implements NewConstants { public Card postFactoryKeywords(Card card){ // this function should handle any keywords that need to be added after a spell goes through the factory + if(hasKeyword(card, "Vanishing") != -1) { + int n = hasKeyword(card, "Vanishing"); + if(n != -1) { + String parse = card.getKeyword().get(n).toString(); + card.removeIntrinsicKeyword(parse); + + String k[] = parse.split(":"); + final int power = Integer.parseInt(k[1]); + + + card.addComesIntoPlayCommand(CardFactoryUtil.vanishing(card, power)); + card.addSpellAbility(CardFactoryUtil.vanish_desc(card, power)); + } + }//Vanishing // Spell has Additional Cost. Reuse Ability_Cost if (hasKeyword(card, "ACost") != -1){ diff --git a/src/forge/CardFactory_Auras.java b/src/forge/CardFactory_Auras.java index 78eb9066117..5e3c70bae16 100644 --- a/src/forge/CardFactory_Auras.java +++ b/src/forge/CardFactory_Auras.java @@ -17,14 +17,6 @@ class CardFactory_Auras { return -1; } - public static int shouldVanish(Card c) { - ArrayList a = c.getKeyword(); - for(int i = 0; i < a.size(); i++) - if(a.get(i).toString().startsWith("Vanishing")) return i; - - return -1; - } - public static int shouldEnchant(Card c) { ArrayList a = c.getKeyword(); for (int i = 0; i < a.size(); i++) @@ -6657,20 +6649,6 @@ class CardFactory_Auras { }// SpellAbility spell }// enControlCreature - if(shouldVanish(card) != -1) { - int n = shouldVanish(card); - if(n != -1) { - String parse = card.getKeyword().get(n).toString(); - card.removeIntrinsicKeyword(parse); - - String k[] = parse.split(":"); - final int power = Integer.parseInt(k[1]); - - card.addComesIntoPlayCommand(CardFactoryUtil.vanishing(card, power)); - card.addSpellAbility(CardFactoryUtil.vanish_desc(card, power)); - } - }//Vanishing - // Cards with Cycling abilities // -1 means keyword "Cycling" not found if(shouldCycle(card) != -1) { diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 8b1050cd8d8..b5f7c26fbd2 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -53,15 +53,7 @@ public class CardFactory_Creatures { return -1; } - public static int shouldVanish(Card c) { - ArrayList a = c.getKeyword(); - for(int i = 0; i < a.size(); i++) - if(a.get(i).toString().startsWith("Vanishing")) return i; - - return -1; - } - - + public static Card getCard(final Card card, String cardName, String owner, CardFactory cf) { //*************** START *********** START ************************** @@ -14797,17 +14789,9 @@ public class CardFactory_Creatures { Command gain2Life = new Command() { private static final long serialVersionUID = 5588978023269625349L; - public boolean firstTime = true; - public void execute() { PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController()); life.addLife(2); - - //testAndSet - only needed when comes into play. - if(firstTime) { - card.addCounter(Counters.TIME, 3); //vanishing - } - firstTime = false; } }; @@ -14816,25 +14800,6 @@ public class CardFactory_Creatures { }//*************** END ************ END ************************** - //*************** START *********** START ************************** - else if(cardName.equals("Calciderm")) { - Command ageCounters = new Command() { - private static final long serialVersionUID = 431920157968451817L; - public boolean firstTime = true; - - public void execute() { - - //testAndSet - only needed when comes into play. - if(firstTime) { - card.addCounter(Counters.TIME, 4); - } - firstTime = false; - } - }; - card.addComesIntoPlayCommand(ageCounters); - - }//*************** END ************ END ************************** - //*************** START *********** START ************************** else if(cardName.equals("Blastoderm")) { Command fadeCounters = new Command() { @@ -21520,20 +21485,6 @@ public class CardFactory_Creatures { } }//Soulshift - if(shouldVanish(card) != -1) { - int n = shouldVanish(card); - if(n != -1) { - String parse = card.getKeyword().get(n).toString(); - card.removeIntrinsicKeyword(parse); - - String k[] = parse.split(":"); - final int power = Integer.parseInt(k[1]); - - card.addComesIntoPlayCommand(CardFactoryUtil.vanishing(card, power)); - card.addSpellAbility(CardFactoryUtil.vanish_desc(card, power)); - } - }//Vanishing - if(hasKeyword(card, "Echo") != -1) { int n = hasKeyword(card, "Echo"); if(n != -1) { diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index e9da6d24c28..9d1bf1cf432 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -119,8 +119,6 @@ public class GameActionUtil { upkeep_Mycoloth(); upkeep_Spore_Counters(); upkeep_Vanishing(); - upkeep_Aven_Riftwatcher(); - upkeep_Calciderm(); upkeep_Blastoderm(); upkeep_Masticore(); upkeep_Eldrazi_Monument(); @@ -7546,40 +7544,6 @@ public class GameActionUtil { } } - - private static void upkeep_Aven_Riftwatcher() { - // get all Aven Riftwatcher in play under the control of this player - final String player = AllZone.Phase.getActivePlayer(); - PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player); - CardList list = new CardList(playZone.getCards()); - list = list.getName("Aven Riftwatcher"); - if(list.size() > 0) { - for(int i = 0; i < list.size(); i++) { - Card card = list.get(i); - card.setCounter(Counters.TIME, card.getCounters(Counters.TIME) - 1); - if(card.getCounters(Counters.TIME) <= 0) { - AllZone.GameAction.sacrifice(card); - } - } - } - } - - private static void upkeep_Calciderm() { - final String player = AllZone.Phase.getActivePlayer(); - PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player); - CardList list = new CardList(playZone.getCards()); - list = list.getName("Calciderm"); - if(list.size() > 0) { - for(int i = 0; i < list.size(); i++) { - Card card = list.get(i); - card.setCounter(Counters.TIME, card.getCounters(Counters.TIME) - 1); - if(card.getCounters(Counters.TIME) <= 0) { - AllZone.GameAction.sacrifice(card); - } - } - } - } - private static void upkeep_Blastoderm() { final String player = AllZone.Phase.getActivePlayer(); PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player);