From be5384314b3f7182f1011d53fadd19883adae2f0 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 03:52:55 +0000 Subject: [PATCH] - Added Unearth + a bunch of Unearth cards. --- res/card-pictures.txt | 1 + res/cards.txt | 90 ++++++++++++++++++++++++++++++++ src/forge/Card.java | 20 +++++++ src/forge/CardFactory.java | 14 +++++ src/forge/CardFactoryUtil.java | 80 +++++++++++++++++++++++++++- src/forge/ComputerUtil.java | 4 +- src/forge/DefaultPlayerZone.java | 10 ++++ src/forge/GameAction.java | 14 +++++ src/forge/GuiDisplay3.java | 4 +- 9 files changed, 232 insertions(+), 5 deletions(-) diff --git a/res/card-pictures.txt b/res/card-pictures.txt index d647f98a017..0e6611348a8 100644 --- a/res/card-pictures.txt +++ b/res/card-pictures.txt @@ -38,6 +38,7 @@ snow_covered_mountain.jpg http://www.wizards.com/global/images/magic/gene snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg +plated_geopede.jpg http://www.wizards.com/global/images/magic/general/plated_geopede.jpg borderland_ranger.jpg http://www.wizards.com/global/images/magic/general/borderland_ranger.jpg city_of_brass.jpg http://www.wizards.com/global/images/magic/general/city_of_brass.jpg channel_the_suns.jpg http://www.wizards.com/global/images/magic/general/channel_the_suns.jpg diff --git a/res/cards.txt b/res/cards.txt index 0b243095628..0b6b4db36b5 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,93 @@ +Vithian Stinger +2 R +Creature Human Shaman +no text +0/1 +abDamageTgtCP T:1 +Unearth:1 R + +Viscera Dragger +3 B +Creature Zombie Ogre Warrior +no text +3/3 +Cycling:2 +Unearth:1 B + +Undead Leotau +5 B +Creature Zombie Cat +no text +3/4 +abPump R:+1/-1 +Unearth:2 B + +Shambling Remains +1 B R +Creature Zombie Horror +no text +4/3 +This creature cannot block +Unearth:B R + +Sedraxis Specter +U B R +Creature +Whenever Sedraxis Specter deals combat damage to a player, that player discards a card. +2/2 +Flying +Unearth:1 B + +Kathari Screecher +2 U +Creature Bird Soldier +no text +2/2 +Flying +Unearth:2 U + +Hell's Thunder +1 R R +Creature Elemental +no text +4/4 +Flying +Haste +At the beginning of the end step, sacrifice CARDNAME. +Unearth:4 R + +Fire-Field Ogre +1 U B R +Creature Ogre Mutant +no text +4/2 +First Strike +Unearth:1 U B R + +Etherium Abomination +3 U B +Artifact Creature Horror +no text +4/3 +Unearth:1 U B + +Dregscape Zombie +1 B +Creature Zombie +no text +2/1 +Unearth:B + +Hellspark Elemental +1 R +Creature Elemental +no text +3/1 +Trample +Haste +At the beginning of the end step, sacrifice CARDNAME. +Unearth:1 R + Borderland Ranger 2 G Creature Human Scout diff --git a/src/forge/Card.java b/src/forge/Card.java index 5251859a4cb..ae4fbcaf377 100644 --- a/src/forge/Card.java +++ b/src/forge/Card.java @@ -57,6 +57,8 @@ public class Card extends MyObservable { private boolean doubleStrike = false; private boolean flashback = false; + private boolean unearth = false; + private boolean unearthed; private int exaltedMagnitude = 0; @@ -1516,6 +1518,24 @@ public class Card extends MyObservable { flashback = b; } + public boolean hasUnearth() { + return unearth; + } + + public void setUnearth(boolean b) { + unearth = b; + } + + public boolean isUnearthed() + { + return unearthed; + } + + public void setUnearthed(boolean b) + { + unearthed = b; + } + public void setKicked(boolean b) { kicked = b; } diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index e3722f92836..d161608c90a 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -2763,6 +2763,20 @@ public class CardFactory implements NewConstants { } }//flashback + if(hasKeyword(card, "Unearth") != -1) { + int n = hasKeyword(card, "Unearth"); + if(n != -1) { + String parse = card.getKeyword().get(n).toString(); + //card.removeIntrinsicKeyword(parse); + + String k[] = parse.split(":"); + + final String manacost = k[1]; + + card.addSpellAbility(CardFactoryUtil.ability_Unearth(card, manacost)); + card.setUnearth(true); + } + }//unearth if(hasKeyword(card, "Devour") != -1) { int n = hasKeyword(card, "Devour"); diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index 077a9f28662..954b7165ad5 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -651,6 +651,74 @@ public class CardFactoryUtil { }//ability_Flashback() + public static Ability ability_Unearth(final Card sourceCard, String manaCost) { + + final Ability unearth = new Ability(sourceCard, manaCost) { + + private static final long serialVersionUID = -5633945565395478009L; + + + @Override + public void resolve() { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, sourceCard.getController()); + //PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, sourceCard.getController()); + PlayerZone play = AllZone.getZone(Constant.Zone.Play, sourceCard.getController()); + + grave.remove(sourceCard); + play.add(sourceCard); + + sourceCard.addIntrinsicKeyword("At the beginning of the end step, sacrifice CARDNAME."); + sourceCard.addIntrinsicKeyword("Haste"); + sourceCard.setUnearthed(true); + /* + final Command entersPlay = new Command() + { + public void execute() + { + sourceCard.setUnearthed(true); + } + }; + sourceCard.addComesIntoPlayCommand(entersPlay); + + + final Command leavesPlay = new Command() + { + private static final long serialVersionUID = -8640915882354670864L; + + public void execute() + { + AllZone.GameAction.removeUnearth(sourceCard); + } + }; + sourceCard.addLeavesPlayCommand(leavesPlay); + */ + + } + + + @Override + public boolean canPlay() { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, sourceCard.getController()); + String phase = AllZone.Phase.getPhase(); + String activePlayer = AllZone.Phase.getActivePlayer(); + + return AllZone.GameAction.isCardInZone(sourceCard, grave) + && ((phase.equals(Constant.Phase.Main1) || phase.equals(Constant.Phase.Main2)) + && sourceCard.getController().equals(activePlayer) && AllZone.Stack.size() == 0); + + } + + }; + + unearth.setFlashBackAbility(true); + //unearth.setManaCost(manaCost); + unearth.setDescription("Unearth: " + manaCost); + unearth.setStackDescription("Unearth: " + sourceCard.getName()); + + return unearth; + + }//ability_Unearth() + public static SpellAbility ability_Spore_Saproling(final Card sourceCard) { final SpellAbility ability = new Ability(sourceCard, "0") { @Override @@ -2649,7 +2717,6 @@ public class CardFactoryUtil { } */ - public static CardList getFlashbackCards(String player) { PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player); CardList cl = new CardList(grave.getCards()); @@ -2660,6 +2727,17 @@ public class CardFactoryUtil { }); return cl; } + + public static CardList getFlashbackUnearthCards(String player) { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player); + CardList cl = new CardList(grave.getCards()); + cl = cl.filter(new CardListFilter() { + public boolean addCard(Card c) { + return c.hasFlashback() || c.hasUnearth(); + } + }); + return cl; + } public static int countOccurrences(String arg1, String arg2) { diff --git a/src/forge/ComputerUtil.java b/src/forge/ComputerUtil.java index 69e58803406..7ea40767a1f 100644 --- a/src/forge/ComputerUtil.java +++ b/src/forge/ComputerUtil.java @@ -108,7 +108,7 @@ public class ComputerUtil } }//play() - //gets Spell's of cards in hand and Abilities of cards in play + //gets Spells of cards in hand and Abilities of cards in play //checks to see //1. if canPlay() returns true, 2. can pay for mana static public SpellAbility[] getSpellAbility() @@ -116,7 +116,7 @@ public class ComputerUtil CardList all = new CardList(); all.addAll(AllZone.Computer_Play.getCards()); all.addAll(AllZone.Computer_Hand.getCards()); - all.addAll(CardFactoryUtil.getFlashbackCards(Constant.Player.Computer).toArray()); + all.addAll(CardFactoryUtil.getFlashbackUnearthCards(Constant.Player.Computer).toArray()); all = all.filter(new CardListFilter() { diff --git a/src/forge/DefaultPlayerZone.java b/src/forge/DefaultPlayerZone.java index 79b6e799f6e..fb4b0f04b7a 100644 --- a/src/forge/DefaultPlayerZone.java +++ b/src/forge/DefaultPlayerZone.java @@ -33,6 +33,16 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl AllZone.GameAction.shuffle(c.getOwner()); return; } + + if (c.isUnearthed() && (is("Graveyard") || is("Hand"))) + { + PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner()); + removed.add(c); + c.setUnearthed(false); + return; + } + + c.addObserver(this); c.setTurnInZone(AllZone.Phase.getTurn()); diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index fe18bd700d4..ff74377f13e 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -63,9 +63,17 @@ public class GameAction { //used by Input_Instant if(p != null) p.remove(c); + //hack: do not reset unearthed + boolean unearthed = false; + if (c.isUnearthed()) + unearthed = true; + //create new Card, which resets stats and anything that might have changed during play if(!c.isToken()) c = AllZone.CardFactory.copyCard(c); + if (unearthed) + c.setUnearthed(true); + zone.add(c); return c; } @@ -751,6 +759,12 @@ public class GameAction { } + public void removeUnearth(Card c) + { + PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner()); + removed.add(c); + } + private boolean shouldDraw = true; private String lastPlayerToDraw = Constant.Player.Human; diff --git a/src/forge/GuiDisplay3.java b/src/forge/GuiDisplay3.java index 566134dd3e7..847dd6b610e 100644 --- a/src/forge/GuiDisplay3.java +++ b/src/forge/GuiDisplay3.java @@ -154,7 +154,7 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo @Override protected Card[] getCards() { - return CardFactoryUtil.getFlashbackCards(Constant.Player.Human).toArray(); + return CardFactoryUtil.getFlashbackUnearthCards(Constant.Player.Human).toArray(); } @Override @@ -461,7 +461,7 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo playerHandValue.setText("" + AllZone.Human_Hand.getCards().length); playerGraveValue.setText("" + AllZone.Human_Graveyard.getCards().length); playerLibraryValue.setText("" + AllZone.Human_Library.getCards().length); - playerFBValue.setText("" + CardFactoryUtil.getFlashbackCards(Constant.Player.Human).size()); + playerFBValue.setText("" + CardFactoryUtil.getFlashbackUnearthCards(Constant.Player.Human).size()); playerRemovedValue.setText("" + AllZone.Human_Removed.getCards().length); }