From 206973c12c0e57e6476f01c9ed0a2956bb362add Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 08:52:25 +0000 Subject: [PATCH] - Changed Fading and Vanishing so they aren't removed as keywords. - Updated subtractCounter to use Vanishing as a keyword. --- src/forge/Card.java | 8 ++------ src/forge/CardFactory.java | 9 ++++----- src/forge/CardFactoryUtil.java | 8 ++------ src/forge/GameActionUtil.java | 18 ++---------------- 4 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/forge/Card.java b/src/forge/Card.java index 659cf9d6742..d21f0b255ff 100644 --- a/src/forge/Card.java +++ b/src/forge/Card.java @@ -390,12 +390,8 @@ public class Card extends MyObservable { counters.put(counterName, aux); if(counterName.equals(Counters.TIME) && aux == 0) { - boolean hasVanish=false; - for(SpellAbility sa:getSpellAbility()) { - if(sa.toString().contains( - "At the beginning of your upkeep, remove a time counter from it. When the last is removed, sacrifice it.)")) //this is essentially ".getDescription()" - hasVanish = true; - } + boolean hasVanish = CardFactory.hasKeyword(this, "Vanishing") != -1; + if(hasVanish && AllZone.GameAction.isCardInPlay(this)) AllZone.GameAction.sacrifice(this); if(hasSuspend() && AllZone.GameAction.isCardRemovedFromGame(this)) diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 3fc3e26ddb9..b914f209537 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -231,7 +231,7 @@ public class CardFactory implements NewConstants { return getCard2(cardName, owner); } - private final int hasKeyword(Card c, String k) { + final static int hasKeyword(Card c, String k) { ArrayList a = c.getKeyword(); for(int i = 0; i < a.size(); i++) if(a.get(i).toString().startsWith(k)) return i; @@ -10924,6 +10924,7 @@ public class CardFactory implements NewConstants { }//getCard2 public Card postFactoryKeywords(Card card){ + // this function should handle any keywords that need to be added after a spell goes through the factory card.addColor(card.getManaCost()); int cardnameSpot = hasKeyword(card, "CARDNAME is "); if (cardnameSpot != -1){ @@ -10939,18 +10940,17 @@ public class CardFactory implements NewConstants { card.addColor(color); } - // this function should handle any keywords that need to be added after a spell goes through the factory if(hasKeyword(card, "Fading") != -1) { int n = hasKeyword(card, "Fading"); 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.fading(card, power)); + // todo: come up with better way to add description card.addSpellAbility(CardFactoryUtil.fading_desc(card, power)); } }//Fading @@ -10959,13 +10959,12 @@ public class CardFactory implements NewConstants { 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)); + // todo: come up with better way to add description card.addSpellAbility(CardFactoryUtil.vanish_desc(card, power)); } }//Vanishing diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index d496190152e..536fbbb3237 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -2258,9 +2258,7 @@ public class CardFactoryUtil { public void resolve() {} }; // Be carefull changing this description cause it's crucial for ability to work (see GameActionUtil - vanishing for it) - desc.setDescription("Fading " - + power - + " (This permanent enters the battlefield with " + desc.setDescription("(This permanent enters the battlefield with " + power + " fade counters on it. At the beginning of your upkeep, remove a fade counter from it. If you can't, sacrifice it.)"); return desc; @@ -2296,9 +2294,7 @@ public class CardFactoryUtil { public void resolve() {} }; // Be carefull changing this description cause it's crucial for ability to work (see GameActionUtil - vanishing for it) - desc.setDescription("Vanishing " - + power - + " (This permanent enters the battlefield with " + desc.setDescription("(This permanent enters the battlefield with " + power + " time counters on it. At the beginning of your upkeep, remove a time counter from it. When the last is removed, sacrifice it.)"); return desc; diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 17864f0aa60..3c341964919 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -7397,14 +7397,7 @@ public class GameActionUtil { CardList list = new CardList(playZone.getCards()); list = list.filter(new CardListFilter() { public boolean addCard(Card c) { - SpellAbility[] sas = c.getSpellAbility(); - boolean hasRegen = false; - for(SpellAbility sa:sas) { - if(sa.toString().contains( - "At the beginning of your upkeep, remove a time counter from it. When the last is removed, sacrifice it.)")) //this is essentially ".getDescription()" - hasRegen = true; - } - return hasRegen; + return CardFactory.hasKeyword(c, "Vanishing") != -1; } }); if(list.size() > 0) { @@ -7431,14 +7424,7 @@ public class GameActionUtil { CardList list = new CardList(playZone.getCards()); list = list.filter(new CardListFilter() { public boolean addCard(Card c) { - SpellAbility[] sas = c.getSpellAbility(); - boolean isFading = false; - for(SpellAbility sa:sas) { - if(sa.toString().contains( - "At the beginning of your upkeep, remove a fade counter from it. If you can't, sacrifice it.)")) //this is essentially ".getDescription()" - isFading = true; - } - return isFading; + return CardFactory.hasKeyword(c, "Fading") != -1; } }); if(list.size() > 0) {