From fd8c083d0193d09c47b0237d788440c17f36383a Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 04:13:04 +0000 Subject: [PATCH] added Explosive Revelation from Rise of the Eldrazi (it's basically like Erratic Explosion, but EE didn't look like it was implemented as the card describes...) --- res/card-pictures.txt | 1 + res/cards.txt | 5 ++ src/forge/CardFactory.java | 106 +++++++++++++++++++++++++++++++++++++ src/forge/GameAction.java | 12 +++++ 4 files changed, 124 insertions(+) diff --git a/res/card-pictures.txt b/res/card-pictures.txt index e312fc7086f..19f06344759 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 +explosive_revelation.jpg http://www.wizards.com/global/images/magic/general/explosive_revelation.jpg acid_rain.jpg http://www.wizards.com/global/images/magic/general/acid_rain.jpg acidic_soil.jpg http://www.wizards.com/global/images/magic/general/acidic_soil.jpg dissipate.jpg http://www.wizards.com/global/images/magic/general/dissipate.jpg diff --git a/res/cards.txt b/res/cards.txt index 16fdc980cbe..226f81f3ce5 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,8 @@ +Explosive Revelation +3 R R +Sorcery +Choose target creature or player. Reveal cards from the top of your library until you reveal a nonland card. Explosive Revelation deals damage equal to that card's converted mana cost to that creature or player. Put the nonland card into your hand and the rest on the bottom of your library in any order. + Acid Rain 3 U Sorcery diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 7937497b5be..c52e84aa175 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -18997,6 +18997,112 @@ public class CardFactory implements NewConstants { card.clearSpellAbility(); card.addSpellAbility(spell); }//*************** END ************ END ************************** + + //*************** START *********** START ************************** + else if(cardName.equals("Explosive Revelation")) { + /* + * Choose target creature or player. Reveal cards from the top of + * your library until you reveal a nonland card. Explosive Revelation + * deals damage equal to that card's converted mana cost to that + * creature or player. Put the nonland card into your hand and the + * rest on the bottom of your library in any order. + */ + final SpellAbility spell = new Spell(card) { + private static final long serialVersionUID = -3234630801871872940L; + + int damage = 3; + Card check; + + @Override + public boolean canPlayAI() { + if(AllZone.Human_Life.getLife() <= damage) return true; + + check = getFlying(); + return check != null; + } + + @Override + public void chooseTargetAI() { + if(AllZone.Human_Life.getLife() <= damage) { + setTargetPlayer(Constant.Player.Human); + return; + } + + Card c = getFlying(); + if((c == null) || (!check.equals(c))) throw new RuntimeException(card + + " error in chooseTargetAI() - Card c is " + c + ", Card check is " + check); + + setTargetCard(c); + }//chooseTargetAI() + + //uses "damage" variable + Card getFlying() { + CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); + for(int i = 0; i < flying.size(); i++) + if(flying.get(i).getNetDefense() <= damage) return flying.get(i); + + return null; + } + + @Override + public void resolve() { + + int damage = getDamage(); + + if(getTargetCard() != null) { + if(AllZone.GameAction.isCardInPlay(getTargetCard()) + && CardFactoryUtil.canTarget(card, getTargetCard())) { + javax.swing.JOptionPane.showMessageDialog(null, cardName+" causes " + damage + + " to " + getTargetCard()); + + Card c = getTargetCard(); + c.addDamage(damage, card); + } + } else { + javax.swing.JOptionPane.showMessageDialog(null, cardName+" causes " + damage + + " to " + getTargetPlayer()); + AllZone.GameAction.addDamage(getTargetPlayer(), damage, card); + } + //System.out.println("Library after: "+AllZoneUtil.getPlayerCardsInLibrary(card.getController())); + } + + int getDamage() { + /* + * Reveal cards from the top of + * your library until you reveal a nonland card. + */ + CardList lib = AllZoneUtil.getPlayerCardsInLibrary(card.getController()); + System.out.println("Library before: "+lib); + CardList revealed = new CardList(); + if( lib.size() > 0 ) { + int index = 0; + Card top; + do { + top = lib.get(index); + //System.out.println("Got from top of library:"+top); + index+= 1; + revealed.add(top); + } while( index < lib.size() && top.isLand() ); + //Display the revealed cards + AllZone.Display.getChoice("Revealed cards:", revealed.toArray()); + //non-land card into hand + AllZone.GameAction.moveToHand(revealed.get(revealed.size()-1)); + //put the rest of the cards on the bottom of library + for(int j = 0; j < revealed.size()-1; j++ ) { + AllZone.GameAction.moveToBottomOfLibrary(revealed.get(j)); + } + //return the damage + + //System.out.println("Explosive Revelation does "+CardUtil.getConvertedManaCost(top)+" from: "+top); + return CardUtil.getConvertedManaCost(top); + } + return 0; + } + };//SpellAbility + card.clearSpellAbility(); + card.addSpellAbility(spell); + spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell, true, false)); + }//*************** END ************ END ************************** // Cards with Cycling abilities // -1 means keyword "Cycling" not found diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index 08df51fdf81..bed3c0b6580 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -102,6 +102,18 @@ public class GameAction { library.add(c, 0); } + /** + * moves a card from whichever Zone it's in to the bottom of its owner's library + * + * @param c the card to move + */ + public void moveToBottomOfLibrary(Card c) { + PlayerZone p = AllZone.getZone(c); + PlayerZone lib = AllZone.getZone(Constant.Zone.Library, c.getOwner()); + if( p != null ) p.remove(c); + if(!c.isToken()) lib.add(c); + } + public void discardRandom(String player) { Card[] c = AllZone.getZone(Constant.Zone.Hand, player).getCards(); if(c.length != 0) discard(CardUtil.getRandom(c));