From 99380d25f36c900840ec050e122a82ca6b80a5ec Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 14:43:52 +0000 Subject: [PATCH] add the missing "return card" ability of The Unspeakable. --- res/cardsfolder/the_unspeakable.txt | 3 +- src/forge/GameActionUtil.java | 48 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/res/cardsfolder/the_unspeakable.txt b/res/cardsfolder/the_unspeakable.txt index 54f4c32c637..63bd3798268 100644 --- a/res/cardsfolder/the_unspeakable.txt +++ b/res/cardsfolder/the_unspeakable.txt @@ -1,11 +1,10 @@ Name:The Unspeakable ManaCost:6 U U U Types:Legendary Creature Spirit -Text:(NOTE: "Whenever The Unspeakable deals combat damage to a player, you may return target Arcane card from your graveyard to your hand." not implemented.) +Text:no text PT:6/7 K:Flying K:Trample -SVar:RemAIDeck:True SVar:Rarity:Rare SVar:Picture:http://resources.wizards.com/magic/cards/chk/en-us/card78693.jpg SetInfo:CHK|Rare|http://magiccards.info/scans/en/chk/98.jpg diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 00a96f73b4a..be7e32ea7db 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -6065,11 +6065,59 @@ public class GameActionUtil { else if(c.getName().equals("Rith, the Awakener")) playerCombatDamage_Rith(c); else if(c.getName().equals("Vorosh, the Hunter")) playerCombatDamage_Vorosh(c); else if(c.getName().equals("Doomsday Specter")) opponent_Discard_Card_You_Choose(c); + else if(c.getName().equals("The Unspeakable")) may_Return_Graveyard_to_Hand(c, "Arcane".split(",")); //Unused variable //c.setDealtCombatDmgToOppThisTurn(true); } + + private static void may_Return_Graveyard_to_Hand(final Card source, final String[] valid) { + final Player player = source.getController(); + final PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player); + final boolean mayReturn = true; + + final SpellAbility returnTgt = new Ability(source, "0") { + + @Override + public void resolve() { + Card target = getTargetCard(); + if (AllZone.GameAction.isCardInZone(target, grave)) { + AllZone.GameAction.moveToHand(target); + } + }//resolve() + };// returnTgt + + + CardList choices = new CardList(grave.getCards()); + choices = choices.getValidCards(valid, player, source); + + if( choices.isEmpty() ) return; + + if( player.isHuman() ) { + if (grave.size() > 0) { + Object o; + if (mayReturn) { + o = AllZone.Display.getChoiceOptional("Select a card", choices.toArray()); + } else { + o = AllZone.Display.getChoice("Select a card", choices.toArray()); + } + if (o != null) { + Card c_1 = (Card) o; + returnTgt.setTargetCard(c_1); + AllZone.Stack.add(returnTgt); + } + } + }// if HumanPlayer + + else { // ComputerPlayer + + if (choices.size() > 0) { + returnTgt.setTargetCard(choices.get(0)); + AllZone.Stack.add(returnTgt); + } + }// ComputerPlayer + } private static void playerCombatDamage_PoisonCounter(Card c, int n) { final Player opponent = c.getController().getOpponent();