From a81b6958490c6470f79289c4b7fb769e6e1448a9 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 03:30:15 +0000 Subject: [PATCH] - Fixed Avenger of Zendikar (will put counters on changeling creatures). - Added Rob's spLoseLife[Tgt] keyword, added the new cards / changed existing cards too. Commented out spLoseLifeGainLife. --- res/cards.txt | 73 +++++++++------ src/forge/CardFactory.java | 135 ++++++++++++++++++++++++++- src/forge/CardFactory_Creatures.java | 19 ++-- src/forge/GameActionUtil.java | 3 +- 4 files changed, 191 insertions(+), 39 deletions(-) diff --git a/res/cards.txt b/res/cards.txt index 997a75d9791..2c2bd1ebc6b 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,50 @@ +Absorb Vis +6 B +Sorcery +no text +spLoseLifeTgt:4:Drawback$YouGainLife/4:Target player loses 4 life and you gain 4 life. +TypeCycling:Basic:1 B + +Last Caress +2 B +Sorcery +no text +spLoseLifeTgt:1:Drawback$YouGainLife/1:Target player loses 1 life and you gain 1 life. +Draw a card. + +Soul Feast +3 B B +Sorcery +no text +spLoseLifeTgt:4:Drawback$YouGainLife/4:Target player loses 4 life and you gain 4 life. + +Morsel Theft +2 B B +Tribal Sorcery Rogue +(NOTE: "Prowl" is not implemented.) +spLoseLifeTgt:3:Drawback$YouGainLife/3:Target player loses 3 life and you gain 3 life.:Morsel Theft - target player 3 loses life and you gain 3 life. + +Exotic Disease +4 B +Sorcery +no text +spLoseLifeTgt:X:Drawback$YouGainLife/X:Domain - Target player loses X life and you gain X life, where X is the number of basic land types among lands you control. +SVar:X:Count$Domain + +Stronghold Discipline +2 B B +Sorcery +no text +spLoseLife:X:Drawback$OppLoseLife/dX:Each player loses 1 life for each creature he or she controls.:Stronghold Discipline - each player loses life +SVar:X:Count$TypeYouCtrl.Creature +SVar:dX:Count$TypeOppCtrl.Creature + +Syphon Life +1 B B +Sorcery +(NOTE: "Retrace" is not implemented.) +spLoseLifeTgt:2:Drawback$YouGainLife/2:Target player loses 2 life and you gain 2 life.:Syphone Life - target player loses life and you gain life + Exhume 1 B Sorcery @@ -2262,13 +2309,6 @@ no text spDamageTgtC:5 TypeCycling:Basic:1 R -Absorb Vis -6 B -Sorcery -no text -spLoseLifeGainLife:4 -TypeCycling:Basic:1 B - Ethereal Usher 5 U Creature Spirit @@ -5845,25 +5885,6 @@ Legendary Creature Human Soldier Creatures you control have horsemanship. 4/4 -Last Caress -2 B -Sorcery -no text -spLoseLifeGainLife:1 -Draw a card. - -Morsel Theft -2 B B -Tribal Sorcery Rogue -(NOTE: "Prowl" is not implemented.) -spLoseLifeGainLife:3 - -Soul Feast -3 B B -Sorcery -no text -spLoseLifeGainLife:4 - Shu Grain Caravan 2 W Creature Human Soldier diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 3e9c7333300..4008cc42d69 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -2737,6 +2737,7 @@ public class CardFactory implements NewConstants { card.addSpellAbility(spDraw); }//spDrawCards + /* //Spell gain life lose life cards (like Soul Feast) if(hasKeyword(card, "spLoseLifeGainLife") != -1) { int n = hasKeyword(card, "spLoseLifeGainLife"); @@ -2792,6 +2793,134 @@ public class CardFactory implements NewConstants { return card; } }// spLoseLifeGainLife + */ + + if (hasKeyword(card, "spLoseLife") != -1) + { + int n = hasKeyword(card, "spLoseLife"); + if (n != -1) + { + String parse = card.getKeyword().get(n).toString(); + card.removeIntrinsicKeyword(parse); + + String k[] = parse.split(":"); + + final boolean Tgt[] = {false}; + Tgt[0] = k[0].contains("Tgt"); + + final int NumLife[] = {-1}; + final String NumLifeX[] = {"none"}; + + if (k[1].matches("X")) + { + String x = card.getSVar(k[1]); + if (x.startsWith("Count$")) + { + String kk[] = x.split("\\$"); + NumLifeX[0] = kk[1]; + } + } + else if (k[1].matches("[0-9][0-9]?")) + NumLife[0] = Integer.parseInt(k[1]); + + // drawbacks and descriptions + final String DrawBack[] = {"none"}; + final String spDesc[] = {"none"}; + final String stDesc[] = {"none"}; + if (k.length > 2) + { + if (k[2].contains("Drawback$")) + { + String kk[] = k[2].split("\\$"); + DrawBack[0] = kk[1]; + if (k.length > 3) + spDesc[0] = k[3]; + if (k.length > 4) + stDesc[0] = k[4]; + } + else + { + if (k.length > 2) + spDesc[0] = k[2]; + if (k.length > 3) + stDesc[0] = k[3]; + } + } + else + { + if (Tgt[0] == true) + { + spDesc[0] = "Target player loses " + NumLife[0] + " life."; + stDesc[0] = cardName + " - target player loses life"; + } + else + { + spDesc[0] = "You lose " + NumLife[0] + " life."; + stDesc[0] = cardName + " - you lose life"; + } + } + + + final SpellAbility spLoseLife = new Spell(card) + { + private static final long serialVersionUID = -8361697584661592092L; + + public int getNumLife() + { + if (NumLife[0] != -1) + return NumLife[0]; + + if (! NumLifeX[0].equals("none")) + return CardFactoryUtil.xCount(card, NumLifeX[0]); + + return 0; + } + + public boolean canPlayAI() + { + if (Tgt[0] == true) + { + setTargetPlayer(Constant.Player.Human); + return true; + } + else // pretty much just for Stronghold Discipline... + { // assumes there's a good Drawback$ that makes losing life worth it + int nlife = getNumLife(); + if ((AllZone.Computer_Life.getLife() - nlife) > 10) + return true; + else + return false; + } + } + + public void resolve() + { + int nlife = getNumLife(); + String TgtPlayer; + + if (Tgt[0] == true) + TgtPlayer = getTargetPlayer(); + else + TgtPlayer = card.getController(); + + AllZone.GameAction.subLife(TgtPlayer, nlife); + + if (!DrawBack[0].equals("none")) + CardFactoryUtil.doDrawBack(DrawBack[0], nlife, card.getController(), AllZone.GameAction.getOpponent(card.getController()), TgtPlayer, card, null); + }//resolve() + };//SpellAbility + + if (Tgt[0] == true) + spLoseLife.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spLoseLife)); + + spLoseLife.setDescription(spDesc[0]); + spLoseLife.setStackDescription(stDesc[0]); + + card.clearSpellAbility(); + card.addSpellAbility(spLoseLife); + } + } + if(hasKeyword(card, "SearchRebel") != -1) { int n = hasKeyword(card, "SearchRebel"); @@ -14125,8 +14254,7 @@ public class CardFactory implements NewConstants { @Override public boolean canPlay() { - CardList gobs = new CardList( - AllZone.getZone(Constant.Zone.Play, card.getController()).getCards()); + CardList gobs = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards()); gobs = gobs.getType("Goblin"); return super.canPlay() && gobs.size() > 0; @@ -14186,8 +14314,7 @@ public class CardFactory implements NewConstants { @Override public void resolve() { if(card.getController().equals(Constant.Player.Computer)) { - CardList gobs = new CardList( - AllZone.getZone(Constant.Zone.Play, card.getController()).getCards()); + CardList gobs = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards()); gobs = gobs.getType("Goblin"); if(gobs.size() > 0) { diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index f70af98e1e7..2ae695c5f9e 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -1091,14 +1091,17 @@ public class CardFactory_Creatures { } */ - List selection = AllZone.Display.getChoices("Select up to two swamps", swamp.toArray()); - - for(int i = 0; i < selection.size(); i++) { - Card c = selection.get(i); - - library.remove(c); - play.add(c); - c.tap(); + if (swamp.size() > 0) + { + List selection = AllZone.Display.getChoices("Select up to two swamps", swamp.toArray()); + + for(int i = 0; i < selection.size(); i++) { + Card c = selection.get(i); + + library.remove(c); + play.add(c); + c.tap(); + } } for(String effect:AllZone.StaticEffects.getStateBasedMap().keySet()) { diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 033d9190164..598a7757917 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -3416,7 +3416,8 @@ public class GameActionUtil { CardList plants = new CardList(play.getCards()); plants = plants.filter(new CardListFilter() { public boolean addCard(Card card) { - return card.isCreature() && card.getType().contains("Plant"); + return card.isCreature() && card.getType().contains("Plant") || + card.getKeyword().contains("Changeling"); } });