diff --git a/.gitattributes b/.gitattributes index 2cdf4f0031b..905b1dbb9fe 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1063,6 +1063,7 @@ res/cardsfolder/crypt_cobra.txt -text svneol=native#text/plain res/cardsfolder/crypt_creeper.txt -text svneol=native#text/plain res/cardsfolder/crypt_of_agadeem.txt -text svneol=native#text/plain res/cardsfolder/crypt_ripper.txt -text svneol=native#text/plain +res/cardsfolder/cryptic_command.txt -text svneol=native#text/plain res/cardsfolder/crystal_ball.txt -text svneol=native#text/plain res/cardsfolder/crystal_quarry.txt -text svneol=native#text/plain res/cardsfolder/crystal_rod.txt -text svneol=native#text/plain diff --git a/res/cardsfolder/cryptic_command.txt b/res/cardsfolder/cryptic_command.txt new file mode 100644 index 00000000000..2fc7eabecd7 --- /dev/null +++ b/res/cardsfolder/cryptic_command.txt @@ -0,0 +1,8 @@ +Name:Cryptic Command +ManaCost:1 U U U +Types:Instant +Text:Choose two - Counter target spell; or return target permanent to its owner's hand; or tap all creatures your opponents control; or draw a card. +SVar:RemAIDeck:True +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/cryptic_command.jpg +End \ No newline at end of file diff --git a/src/forge/CardFactory_Instants.java b/src/forge/CardFactory_Instants.java index f746d2db9e6..1eb8a4af106 100644 --- a/src/forge/CardFactory_Instants.java +++ b/src/forge/CardFactory_Instants.java @@ -4155,6 +4155,181 @@ public class CardFactory_Instants { card.addSpellAbility(spell); }//*************** END ************ END ************************** + + //*************** START *********** START ************************** + else if(cardName.equals("Cryptic Command")) { + final SpellAbility[] m_spell = new SpellAbility[1]; + final Card[] m_perm = new Card[1]; + + final ArrayList userChoice = new ArrayList(); + + final String[] cardChoice = { + "Counter target spell", + "Return target permanent to its owner's hand", + "Tap all creatures your opponents control", + "Draw a card"}; + + final SpellAbility spell = new Spell(card) { + private static final long serialVersionUID = 9178547049760990376L; + + @Override + public void resolve() { + + //"Counter target spell", + for(int i = 0; i 0) { + SpellAbility sa = AllZone.Stack.peek(); + if(sa.isSpell()) { + AllZone.Stack.pop(); + AllZone.GameAction.moveToGraveyard(sa.getSourceCard()); + } + } + } + } + + //"Return target Permanent to its owner's hand", + if(userChoice.contains(cardChoice[1]) || card.getChoices().contains(cardChoice[1])) { + if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard())) { + AllZone.GameAction.moveToHand(getTargetCard()); + } + } + + //"Tap all creatures your opponents control", + for(int i = 0; i a = new ArrayList(); + if(userChoice.contains(cardChoice[0]) || card.getChoices().contains(cardChoice[0])) a.add("counter target spell"); + if(userChoice.contains(cardChoice[1]) || card.getChoices().contains(cardChoice[1])) a.add("return target permanent to its owner's hand"); + if(userChoice.contains(cardChoice[2]) || card.getChoices().contains(cardChoice[2])) a.add("tap all creatures your opponents control"); + if(userChoice.contains(cardChoice[3]) || card.getChoices().contains(cardChoice[3])) a.add(" Draw a card."); + + String s = a.get(0) + ", " + a.get(1); + spell.setStackDescription(card.getName() + " - " + s); + } + };//Command + + + final Input returnTarget = new Input() { + private static final long serialVersionUID = 2736368243448655071L; + + @Override + public void showMessage() { + AllZone.Display.showMessage("Select target permanent"); + ButtonUtil.enableOnlyCancel(); + } + + @Override + public void selectButtonCancel() { + stop(); + } + + @Override + public void selectCard(Card c, PlayerZone zone) { + if(c.isPermanent() && zone.is(Constant.Zone.Battlefield) && CardFactoryUtil.canTarget(card, c)) { + if(card.isCopiedSpell()) card.getChoiceTargets().remove(0); + m_perm[0] = c; + spell.setTargetCard(c); + card.setSpellChoiceTarget(String.valueOf(c.getUniqueNumber())); + setStackDescription.execute(); + stopSetNext(new Input_PayManaCost(spell)); + }//if + }//selectCard() + };//Input targetLand + + Input chooseTwoInput = new Input() { + private static final long serialVersionUID = -4200213000203960667L; + + @Override + public void showMessage() { + if(card.isCopiedSpell()) { + if(card.getChoices().contains(cardChoice[1])) stopSetNext(returnTarget); + else { + setStackDescription.execute(); + + stopSetNext(new Input_PayManaCost(spell)); + } + } + else { + //reset variables + m_spell[0] = null; + m_perm[0] = null; + card.getChoices().clear(); + card.getChoiceTargets().clear(); + userChoice.clear(); + + ArrayList display = new ArrayList(); + + //get all + CardList list = AllZoneUtil.getCardsInPlay(); + + if(AllZone.Stack.size() > 0) display.add("Counter target spell"); + if(list.size() > 0) display.add("Return target permanent to its owner's hand"); + display.add("Tap all creatures your opponents control"); + display.add("Draw a card"); + + ArrayList a = chooseTwo(display); + //everything stops here if user cancelled + if(a == null) { + stop(); + return; + } + + userChoice.addAll(a); + + if(userChoice.contains(cardChoice[1])) stopSetNext(returnTarget); + else { + setStackDescription.execute(); + stopSetNext(new Input_PayManaCost(spell)); + } + } + }//showMessage() + + ArrayList chooseTwo(ArrayList choices) { + ArrayList out = new ArrayList(); + Object o = AllZone.Display.getChoiceOptional("Choose Two", choices.toArray()); + if(o == null) return null; + + out.add((String) o); + card.addSpellChoice((String) o); + choices.remove(out.get(0)); + o = AllZone.Display.getChoiceOptional("Choose Two", choices.toArray()); + if(o == null) return null; + + out.add((String) o); + card.addSpellChoice((String) o); + return out; + }//chooseTwo() + };//Input chooseTwoInput + + card.clearSpellAbility(); + card.addSpellAbility(spell); + card.setSpellWithChoices(true); + spell.setBeforePayMana(chooseTwoInput); + }//*************** END ************ END ************************** + return card; }//getCard }