From 1811cbbfb6adc3718ac989880132be05b64d73c0 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 05:03:50 +0000 Subject: [PATCH] - Added Oath of Ghouls - Cleaned up Code for Oversold Cemetery --- res/card-pictures.txt | 1 + res/cards.txt | 5 +++ res/rare.txt | 1 + src/forge/AllZoneUtil.java | 33 ++++++++++++++- src/forge/GameActionUtil.java | 76 ++++++++++++++++++++++++----------- 5 files changed, 92 insertions(+), 24 deletions(-) diff --git a/res/card-pictures.txt b/res/card-pictures.txt index d7ac315ca2d..098920a283f 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 +oath_of_ghouls.jpg http://www.wizards.com/global/images/magic/general/oath_of_ghouls.jpg darba.jpg http://www.wizards.com/global/images/magic/general/darba.jpg molting_harpy.jpg http://www.wizards.com/global/images/magic/general/molting_harpy.jpg phantasmal_forces.jpg http://www.wizards.com/global/images/magic/general/phantasmal_forces.jpg diff --git a/res/cards.txt b/res/cards.txt index e7b5877a12a..bea48ad0c0d 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,8 @@ +Oath of Ghouls +1 B +Enchantment +At the beginning of each player's upkeep, that player chooses target player whose graveyard has fewer creature cards in it than his or her graveyard does and is his or her opponent. The first player may return a creature card from his or her graveyard to his or her hand. + Darba 3 G Creature Bird Beast diff --git a/res/rare.txt b/res/rare.txt index 2e6ddfaef43..e06ce1fcacf 100644 --- a/res/rare.txt +++ b/res/rare.txt @@ -555,6 +555,7 @@ Noble Panther Nova Chaser Novablast Wurm Nyxathid +Oath of Ghouls Oath of Druids Ob Nixilis, the Fallen Obliterate diff --git a/src/forge/AllZoneUtil.java b/src/forge/AllZoneUtil.java index 1560597960e..49564ccee93 100644 --- a/src/forge/AllZoneUtil.java +++ b/src/forge/AllZoneUtil.java @@ -303,6 +303,18 @@ public class AllZoneUtil { return cards; } + /** + * gets a list of all cards of a certain type that a given player has in graveyard + * @param player the player to check for cards in play + * @param cardType the card type to check for + * @return a CardList with all cards of a certain type the player has in graveyard + */ + public static CardList getPlayerTypeInGraveyard(final String player, final String cardType) { + CardList cards = getPlayerGraveyard(player); + cards = cards.getType(cardType); + return cards; + } + ////////////// cardListFilter for different types public static CardListFilter artifacts = new CardListFilter() { public boolean addCard(Card c) { @@ -369,6 +381,25 @@ public class AllZoneUtil { } } + public static int CompareTypeAmountInPlay(final String player, String type) + { + // returns the difference between player's + String opponent = AllZone.GameAction.getOpponent(player); + CardList playerList = getPlayerTypeInPlay(player, type); + CardList opponentList = getPlayerTypeInPlay(opponent, type); + return (playerList.size() - opponentList.size()); + } + + public static int CompareTypeAmountInGraveyard(final String player, String type) + { + // returns the difference between player's + String opponent = AllZone.GameAction.getOpponent(player); + CardList playerList = getPlayerTypeInGraveyard(player, type); + CardList opponentList = getPlayerTypeInGraveyard(opponent, type); + return (playerList.size() - opponentList.size()); + } + + /** * a CardListFilter to get all cards that are tapped */ @@ -403,5 +434,5 @@ public class AllZoneUtil { public boolean addCard(Card c) { return !c.isEnchanted(); } - }; + }; } \ No newline at end of file diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index b3685d83a8a..6f877f14f49 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -104,6 +104,7 @@ public class GameActionUtil { upkeep_Karma(); upkeep_Defense_of_the_Heart(); upkeep_Oath_of_Druids(); + upkeep_Oath_of_Ghouls(); upkeep_Mycoloth(); upkeep_Spore_Counters(); upkeep_Vanishing(); @@ -4794,7 +4795,7 @@ public class GameActionUtil { life.setLife(lifeGain); } }; - ability.setStackDescription("Landfall — Whenever a land enters the battlefield under your control, you may have your life total become the number of charge counters on Eternity Vessel."); + ability.setStackDescription("Landfall: Whenever a land enters the battlefield under your control, you may have your life total become the number of charge counters on Eternity Vessel."); if(c.getController().equals(Constant.Player.Human)) { if(showLandfallDialog(c)) AllZone.Stack.add(ability); @@ -6929,51 +6930,41 @@ public class GameActionUtil { private static void upkeep_Oversold_Cemetery() { final String player = AllZone.Phase.getActivePlayer(); - PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player); - PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, player); - CardList creatures = new CardList(graveyard.getCards()); - creatures = creatures.getType("Creature"); + CardList graveyardCreatures = AllZoneUtil.getPlayerTypeInGraveyard(player, "Creature"); + CardList cemeteryList = AllZoneUtil.getCardsInPlay("Oversold Cemetery"); - CardList list = new CardList(playZone.getCards()); - list = list.getName("Oversold Cemetery"); - - if(creatures.size() >= 4) { - for(int i = 0; i < list.size(); i++) { - Ability ability = new Ability(list.get(0), "0") { + if(graveyardCreatures.size() >= 4) { + for(int i = 0; i < cemeteryList.size(); i++) { + Ability ability = new Ability(cemeteryList.get(0), "0") { @Override public void resolve() { + CardList graveyardCreatures = AllZoneUtil.getPlayerTypeInGraveyard(player, "Creature"); PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, player); PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player); - CardList creatures = new CardList(graveyard.getCards()); - creatures = creatures.getType("Creature"); - - if(creatures.size() >= 4) { + if(graveyardCreatures.size() >= 4) { if(player.equals("Human")) { Object o = AllZone.Display.getChoiceOptional("Pick a creature to return to hand", - creatures.toArray()); + graveyardCreatures.toArray()); if(o != null) { Card card = (Card) o; graveyard.remove(card); hand.add(card); } - } else if(player.equals("Computer")) { - Card card = creatures.get(0); + } + else if(player.equals("Computer")) { + Card card = graveyardCreatures.get(0); graveyard.remove(card); hand.add(card); - } } } - };// Ability ability.setStackDescription("Oversold Cemetary returns creature from the graveyard to its owner's hand."); AllZone.Stack.add(ability); - } } - }//Oversold Cemetery private static void upkeep_Reya() { @@ -7448,7 +7439,46 @@ public class GameActionUtil { } }// if - }// upkeep_Oath of Druids() + }// upkeep_Oath of Druids() + + private static void upkeep_Oath_of_Ghouls() { + final String player = AllZone.Phase.getActivePlayer(); + CardList oathList = AllZoneUtil.getCardsInPlay("Oath of Ghouls"); + + if (AllZoneUtil.CompareTypeAmountInGraveyard(player, "Creature") > 0) + { + for(int i = 0; i < oathList.size(); i++) + { + Ability ability = new Ability(oathList.get(0), "0") { + @Override + public void resolve() { + CardList graveyardCreatures = AllZoneUtil.getPlayerTypeInGraveyard(player, "Creature"); + PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, player); + PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player); + + if(AllZoneUtil.CompareTypeAmountInGraveyard(player, "Creature") > 0) { + if(player.equals("Human")) { + Object o = AllZone.Display.getChoiceOptional("Pick a creature to return to hand", + graveyardCreatures.toArray()); + if(o != null) { + Card card = (Card) o; + graveyard.remove(card); + hand.add(card); + } + } + else if(player.equals("Computer")) { + Card card = graveyardCreatures.get(0); + graveyard.remove(card); + hand.add(card); + } + } + } + };// Ability + ability.setStackDescription("At the beginning of each player's upkeep, Oath of Ghouls returns a creature from their graveyard to owner's hand if they have more than an opponent."); + AllZone.Stack.add(ability); + } + } + }//Oath of Ghouls private static void upkeep_Karma() { final String player = AllZone.Phase.getActivePlayer();