mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Convert Cryptic Command to script
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
Name:Cryptic Command
|
Name:Cryptic Command
|
||||||
ManaCost:1 U U U
|
ManaCost:1 U U U
|
||||||
Types:Instant
|
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.
|
Text:
|
||||||
|
A:SP$ Charm | Cost$ 1 U U U | Choices$ DBCounter,DBReturn,DBTapAll,DBDraw | CharmNum$ 2 | SpellDescription$ 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:DBCounter:DB$ Counter | TargetType$ Spell | ValidTgts$ Card | SpellDescription$ Counter target spell.
|
||||||
|
SVar:DBReturn:DB$ ChangeZone | Origin$ Battlefield | Destination$ Hand | ValidTgts$ Permanent | TgtPrompt$ Select target permanent | SpellDescription$ Return target permanent to its owner's hand.
|
||||||
|
SVar:DBTapAll:DB$ TapAll | ValidCards$ Creature.YouDontCtrl | SpellDescription$ Tap all creatures your opponents control.
|
||||||
|
SVar:DBDraw:DB$ Draw | Defined$ You | NumCards$ 1 | SpellDescription$ Draw a card.
|
||||||
SVar:RemAIDeck:True
|
SVar:RemAIDeck:True
|
||||||
SVar:Rarity:Rare
|
SVar:Rarity:Rare
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/cryptic_command.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/cryptic_command.jpg
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import forge.gui.input.Input;
|
|||||||
import forge.gui.input.Input_PayManaCost;
|
import forge.gui.input.Input_PayManaCost;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -994,206 +993,6 @@ public class CardFactory_Instants {
|
|||||||
}//*************** END ************ END **************************
|
}//*************** 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<String> userChoice = new ArrayList<String>();
|
|
||||||
|
|
||||||
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 < card.getChoices().size(); i++) {
|
|
||||||
if (card.getChoice(i).equals(cardChoice[0])) {
|
|
||||||
if (AllZone.getStack().size() > 0) {
|
|
||||||
SpellAbility sa = AllZone.getStack().peekAbility();
|
|
||||||
if (sa.isSpell()) {
|
|
||||||
AllZone.getStack().pop();
|
|
||||||
AllZone.getGameAction().moveToGraveyard(sa.getSourceCard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//"Return target Permanent to its owner's hand",
|
|
||||||
if (userChoice.contains(cardChoice[1]) || card.getChoices().contains(cardChoice[1])) {
|
|
||||||
if (AllZoneUtil.isCardInPlay(getTargetCard())
|
|
||||||
&& CardFactoryUtil.canTarget(card, getTargetCard()))
|
|
||||||
{
|
|
||||||
AllZone.getGameAction().moveToHand(getTargetCard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//"Tap all creatures your opponents control",
|
|
||||||
for (int i = 0; i < card.getChoices().size(); i++) {
|
|
||||||
if (card.getChoice(i).equals(cardChoice[2])) {
|
|
||||||
CardList creatures = AllZoneUtil.getCreaturesInPlay(card.getController().getOpponent());
|
|
||||||
for (Card c : creatures) {
|
|
||||||
c.tap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//"Draw a card"
|
|
||||||
if (userChoice.contains(cardChoice[3]) || card.getChoices().contains(cardChoice[3])) {
|
|
||||||
card.getController().drawCard();
|
|
||||||
}
|
|
||||||
} //resolve()
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayAI() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}; //SpellAbility
|
|
||||||
|
|
||||||
final Command setStackDescription = new Command() {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -4833850318955216009L;
|
|
||||||
|
|
||||||
public void execute() {
|
|
||||||
ArrayList<String> a = new ArrayList<String>();
|
|
||||||
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.getDisplay().showMessage("Select target permanent");
|
|
||||||
ButtonUtil.enableOnlyCancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectButtonCancel() {
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectCard(final Card c, final 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<String> display = new ArrayList<String>();
|
|
||||||
|
|
||||||
//get all
|
|
||||||
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
|
||||||
|
|
||||||
if (AllZone.getStack().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<String> 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<String> chooseTwo(final ArrayList<String> choices) {
|
|
||||||
ArrayList<String> out = new ArrayList<String>();
|
|
||||||
Object o = GuiUtils.getChoiceOptional("Choose Two", choices.toArray());
|
|
||||||
if (o == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
out.add((String) o);
|
|
||||||
card.addSpellChoice((String) o);
|
|
||||||
choices.remove(out.get(0));
|
|
||||||
o = GuiUtils.getChoiceOptional("Choose Two", choices.toArray());
|
|
||||||
if (o == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
out.add((String) o);
|
|
||||||
card.addSpellChoice((String) o);
|
|
||||||
return out;
|
|
||||||
} //chooseTwo()
|
|
||||||
}; //Input chooseTwoInput
|
|
||||||
|
|
||||||
card.addSpellAbility(spell);
|
|
||||||
|
|
||||||
card.setSpellWithChoices(true);
|
|
||||||
spell.setBeforePayMana(chooseTwoInput);
|
|
||||||
} //*************** END ************ END **************************
|
|
||||||
|
|
||||||
|
|
||||||
//*************** START *********** START **************************
|
//*************** START *********** START **************************
|
||||||
else if (cardName.equals("Remove Enchantments")) {
|
else if (cardName.equals("Remove Enchantments")) {
|
||||||
final SpellAbility spell = new Spell(card) {
|
final SpellAbility spell = new Spell(card) {
|
||||||
|
|||||||
Reference in New Issue
Block a user