From 939f8fbed7b4b345357b690195a4ffd61434b342 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 03:51:39 +0000 Subject: [PATCH] - Added slapshot5's code for Crumble, The Rack, Flashfires and Karma. --- res/card-pictures.txt | 4 ++ res/cards.txt | 38 +++++++++++------ src/forge/CardFactory.java | 75 ++++++++++++++++++++++++++++++++ src/forge/GameActionUtil.java | 80 ++++++++++++++++++++++++++++++++++- 4 files changed, 183 insertions(+), 14 deletions(-) diff --git a/res/card-pictures.txt b/res/card-pictures.txt index fd0bb27244b..b32ded3ee04 100644 --- a/res/card-pictures.txt +++ b/res/card-pictures.txt @@ -38,6 +38,10 @@ 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 +the_rack.jpg http://www.wizards.com/global/images/magic/general/the_rack.jpg +crumble.jpg http://www.wizards.com/global/images/magic/general/crumble.jpg +flashfires.jpg http://www.wizards.com/global/images/magic/general/flashfires.jpg +karma.jpg http://www.wizards.com/global/images/magic/general/karma.jpg clinging_darkness.jpg http://www.wizards.com/global/images/magic/general/clinging_darkness.jpg enfeeblement.jpg http://www.wizards.com/global/images/magic/general/enfeeblement.jpg feebleness.jpg http://www.wizards.com/global/images/magic/general/feebleness.jpg diff --git a/res/cards.txt b/res/cards.txt index fd54ba72a8e..a9b9e3158b1 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,23 @@ +The Rack +1 +Artifact +At the beginning of opponent's upkeep, The Rack deals X damage to that player, where X is 3 minus the number of cards in his or her hand. + +Crumble +G +Instant +Destroy target artifact. It can't be regenerated. That artifact's controller gains life equal to its converted mana cost. + +Flashfires +3 R +Sorcery +Destroy all Plains. + +Karma +2 W W +Enchantment +At the beginning of each player's upkeep, Karma deals damage to that player equal to the number of Swamps he or she controls. + Clinging Darkness 1 B Enchantment Aura @@ -88,7 +108,6 @@ Paralyzing Grasp Enchantment Aura Enchanted creature doesn't untap during its controller's untap step. Enchant creature -enPumpCurse:This card doesn't untap during your untap step. Artifact Ward W @@ -4720,9 +4739,8 @@ Eternity Snare 5 U Enchantment Aura Enchanted creature doesn't untap during its controller's untap step. -Enchant creature -enPumpCurse:This card doesn't untap during your untap step. When this card comes into play, draw a card. +Enchant creature Elvish Hunter 1 G @@ -4966,10 +4984,9 @@ enPump:+3/+0/First Strike Despondency 1 B Enchantment Aura -Enchanted creature gets -2/-0. -Enchant creature -enPumpCurse:-2/-0 +Enchanted creature gets -2/+0. When this card is put into a graveyard from the battlefield, return this card to its owner's hand +Enchant creature Snow-Covered Forest no cost @@ -5567,23 +5584,20 @@ Cessation 2 W Enchantment Aura Enchanted creature can't attack. -Enchant creature -enPumpCurse:This creature can't attack When this card is put into a graveyard from the battlefield, return this card to its owner's hand +Enchant creature Pacifism 1 W Enchantment Aura Enchanted creature can't attack or block. Enchant creature -enPumpCurse:This creature can't attack or block Bound in Silence 2 W Tribal Enchantment Rebel Aura Enchanted creature can't attack or block. Enchant creature -enPumpCurse:This creature can't attack or block Barrenton Cragtreads 2 WU WU @@ -6577,9 +6591,8 @@ Sluggishness 1 R Enchantment Aura Enchanted creature can't block. -Enchant creature -enPumpCurse:This creature cannot block When this card is put into a graveyard from the battlefield, return this card to its owner's hand +Enchant creature Aspect of Mongoose 1 G @@ -8025,7 +8038,6 @@ B Enchantment Aura Enchanted creature gets -2/-1. Enchant creature -enPumpCurse:-2/-1 Unholy Strength B diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index a31f53ec05a..8e455a68b23 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -17255,6 +17255,81 @@ public class CardFactory implements NewConstants { } //*************** END ************ END ************************** + //*************** START *********** START ************************** + else if(cardName.equals("Flashfires")) { + final SpellAbility spell = new Spell(card) { + private static final long serialVersionUID = -5951776277564352958L; + + @Override + public void resolve() { + CardList all = new CardList(); + all.addAll(AllZone.Human_Play.getCards()); + all.addAll(AllZone.Computer_Play.getCards()); + + for(int i = 0; i < all.size(); i++) { + Card c = all.get(i); + if(c.getType().contains("Plains")) AllZone.GameAction.destroy(c); + } + }//resolve() + + @Override + public boolean canPlayAI() { + CardList list = new CardList(AllZone.Human_Play.getCards()); + list = list.getType("Plains"); + + return 3 < list.size(); + } + };//SpellAbility + spell.setStackDescription(card.getName() + " - destroy all Plains."); + card.clearSpellAbility(); + card.addSpellAbility(spell); + }//*************** END ************ END ************************** + + //*************** START *********** START ************************** + else if(cardName.equals("Crumble")) { + SpellAbility spell = new Spell(card) { + private static final long serialVersionUID = 4752943254606319269L; + + @Override + public void resolve() { + if(AllZone.GameAction.isCardInPlay(getTargetCard()) + && CardFactoryUtil.canTarget(card, getTargetCard())) { + //add life + String player = getTargetCard().getController(); + PlayerLife life = AllZone.GameAction.getPlayerLife(player); + life.addLife(CardUtil.getConvertedManaCost(getTargetCard())); + + //remove card from play + AllZone.GameAction.removeFromGame(getTargetCard()); + } + }//resolve() + + @Override + public boolean canPlayAI() { + CardList artifacts = new CardList(AllZone.Human_Play.getCards()); + artifacts = artifacts.getType("Artifact"); + artifacts = artifacts.filter(new CardListFilter() { + public boolean addCard(Card c) { + return CardFactoryUtil.canTarget(card, c); + } + }); + return artifacts.size() != 0 && (AllZone.Phase.getTurn() > 4); + } + + @Override + public void chooseTargetAI() { + CardList play = new CardList(AllZone.Human_Play.getCards()); + Card target = CardFactoryUtil.AI_getBestArtifact(play); + if(target != null) setTargetCard(target); + } + }; + spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell, "Artifact")); + + card.clearSpellAbility(); + card.addSpellAbility(spell); + }//*************** END ************ END ************************** + + // Cards with Cycling abilities // -1 means keyword "Cycling" not found if(hasKeyword(card, "Cycling") != -1) { diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 4e4f947b22b..5f7f54c5589 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -73,6 +73,7 @@ public class GameActionUtil { upkeep_Klass(); upkeep_Convalescence(); upkeep_Convalescent_Care(); + upkeep_Karma(); upkeep_Defense_of_the_Heart(); upkeep_Mycoloth(); upkeep_Spore_Counters(); @@ -86,6 +87,7 @@ public class GameActionUtil { upkeep_Dark_Confidant(); // keep this one semi-last upkeep_Copper_Tablet(); + upkeep_The_Rack(); upkeep_BlackVise(); upkeep_Ivory_Tower(); @@ -5701,6 +5703,43 @@ public class GameActionUtil { }// if }// upkeep_Defense of the Heart + private static void upkeep_Karma() { + final String player = AllZone.Phase.getActivePlayer(); + String opponent = AllZone.GameAction.getOpponent(player); + + PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Play, opponent); + + CardList karma = new CardList(opponentPlayZone.getCards()); + karma = karma.getName("Karma"); + + PlayerZone activePlayZone = AllZone.getZone(Constant.Zone.Play, player); + CardList swamps = new CardList(activePlayZone.getCards()); + swamps = swamps.getType("Swamp"); + + // determine how much damage to deal the current player + final int damage = swamps.size(); + + // if there are 1 or more Karmas owned by the opponent of the + // current player have each of them deal damage. + if(0 < karma.size()) { + for(int i = 0; i < karma.size(); i++) { + Ability ability = new Ability(karma.get(0), "0") { + @Override + public void resolve() { + if(damage>0){ + PlayerLife life = AllZone.GameAction.getPlayerLife(player); + life.setLife(life.getLife() - damage); + } + } + };// Ability + if(damage>0){ + ability.setStackDescription("Karma deals " + damage + " damage to " + player); + AllZone.Stack.add(ability); + } + } + }// if + }// upkeep_Karma() + private static void upkeep_Convalescence() { final String player = AllZone.Phase.getActivePlayer(); PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player); @@ -5785,7 +5824,46 @@ public class GameActionUtil { }//for }//upkeep_Ivory Tower() - + //Forge doesn't distinguish between beginning and end of upkeep + //so, we'll put The Rack next to Black Vise + private static void upkeep_The_Rack() { + // sanity check. If a player has >= 3 cards The Rack does nothing. + final String player = AllZone.Phase.getActivePlayer(); + final int playerHandSize = AllZone.getZone(Constant.Zone.Hand, player).size(); + + if(playerHandSize >= 3) { + return; + } + + // if a player has 2 or fewer cards The Rack does damage + // so, check if opponent of the current player has The Rack + String opponent = AllZone.GameAction.getOpponent(player); + + PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Play, opponent); + + CardList theRack = new CardList(opponentPlayZone.getCards()); + theRack = theRack.getName("The Rack"); + + // determine how much damage to deal the current player + final int damage = 3 - playerHandSize; + + // if there are 1 or more The Racks owned by the opponent of the + // current player have each of them deal damage. + if(0 < theRack.size()) { + for(int i = 0; i < theRack.size(); i++) { + Ability ability = new Ability(theRack.get(0), "0") { + @Override + public void resolve() { + PlayerLife life = AllZone.GameAction.getPlayerLife(player); + life.setLife(life.getLife() - damage); + } + };// Ability + + ability.setStackDescription("The Rack - deals " + damage + " damage to " + player); + AllZone.Stack.add(ability); + } + }// if + }// upkeep_The_Rack // Currently we don't determine the difference between beginning and end of // upkeep in MTG forge.