spDiscard[Tgt|Opp]

Finally assembled this keyword.. I had begun working on it a couple months ago.
Right now it only handles basic discards, where the targeted player or opponent chooses. The reveal and choose type are next, and will be part of the same keyword.
Syntax:
Right now it only handles basic discards, where the targeted player or opponent chooses. The reveal and choose type are next, and will be part of the same keyword.
Syntax:
- Code: Select all
spDiscard[Tgt|Opp]:[TgtChoose|OppChoose|AtRandom|Hand]:<numCards>:<Drawback:Spell Description:StackDescription>
- Code: Select all
if (hasKeyword(card, "spDiscard") != -1)
{
int n = hasKeyword(card, "spDiscard");
String parse = card.getKeyword().get(n).toString();
card.removeIntrinsicKeyword(parse);
String k[] = parse.split(":");
final boolean Tgt = k[0].contains("Tgt");
final boolean Opp = k[0].contains("Opp");
final String DiscardMethod = k[1];
final int NumCards[] = {-1138};
final String NumCardsX[] = {"none"};
final String UnlessType[] = {"none"};
if (k[2].length() > 1)
{
String kk[] = k[2].split("/");
if (kk[1].startsWith("UnlessDiscardType"))
{
String jk[] = kk[1].split("\\.");
UnlessType[0] = jk[1];
}
}
else if (k[2].matches("X"))
{
String xy = card.getSVar(k[2]);
if (xy.startsWith("Count$"))
{
String kk[] = xy.split("\\$");
NumCardsX[0] = kk[1];
}
}
else if (k[2].matches("[0-9]"))
{
NumCards[0] = Integer.parseInt(k[2]);
}
final String Drawback[] = {"none"};
final String spDesc[] = {"none"};
final String stDesc[] = {"none"};
if (k[3].contains("Drawback$"))
{
String kk[] = k[3].split("\\$");
Drawback[0] = kk[1];
if (k.length > 4) spDesc[0] = k[4];
if (k.length > 5) stDesc[0] = k[5];
}
else
{
if (k.length > 3) spDesc[0] = k[3];
if (k.length > 4) stDesc[0] = k[4];
}
SpellAbility spDiscard = new Spell(card)
{
private static final long serialVersionUID = 837472987492L;
private int getNumCards() {
if(NumCards[0] != -1138) return NumCards[0];
if(!NumCardsX[0].equals("none")) return CardFactoryUtil.xCount(card, NumCardsX[0]);
return 0;
}
public boolean canPlayAI()
{
int nCards = getNumCards();
PlayerZone pzH = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Human);
int numHHand = pzH.size();
if (numHHand > (nCards - 1))
return true;
return false;
}
public void resolve()
{
int nCards = getNumCards();
if (DiscardMethod.equals("OppChoose"))
{
String opp = AllZone.GameAction.getOpponent(card.getController());
if (!UnlessType[0].equals("none"))
AllZone.GameAction.discardUnless(opp, nCards, UnlessType[0]);
else
AllZone.GameAction.discard(opp, nCards);
}
else if (DiscardMethod.equals("TgtChoose"))
{
if (!UnlessType[0].equals("none"))
AllZone.GameAction.discardUnless(getTargetPlayer(), nCards, UnlessType[0]);
else
AllZone.GameAction.discard(getTargetPlayer(), nCards);
}
else if (DiscardMethod.equals("AtRandom"))
{
AllZone.GameAction.discardRandom(getTargetPlayer(), nCards);
}
else if (DiscardMethod.equals("Hand"))
{
AllZone.GameAction.discardHand(getTargetPlayer());
}
if (!Drawback[0].equals("none"))
{
CardFactoryUtil.doDrawBack(Drawback[0], 0, card.getController(), AllZone.GameAction.getOpponent(card.getController()), card.getController(), card, card);
}
}
};
if (Tgt)
spDiscard.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spDiscard));
else
spDiscard.setTargetPlayer(AllZone.GameAction.getOpponent(card.getController()));
spDiscard.setDescription(spDesc[0]);
spDiscard.setStackDescription(stDesc[0]);
card.clearSpellAbility();
card.addSpellAbility(spDiscard);
String bbCost = card.getSVar("Buyback");
if (!bbCost.equals(""))
{
SpellAbility bbDiscardTgt = spDiscard.copy();
bbDiscardTgt.setManaCost(CardUtil.addManaCosts(card.getManaCost(), bbCost));
bbDiscardTgt.setDescription("Buyback " + bbCost + "(You may pay an additional " + bbCost + " as you cast this spell. If you do, put this card into your hand as it resolves.)");
bbDiscardTgt.setIsBuyBackAbility(true);
if (Tgt)
bbDiscardTgt.setBeforePayMana(CardFactoryUtil.input_targetPlayer(bbDiscardTgt));
else
bbDiscardTgt.setTargetPlayer(AllZone.GameAction.getOpponent(card.getController()));
card.addSpellAbility(bbDiscardTgt);
}
}//spDiscardTgt
- Code: Select all
Unnerve
3 B
Sorcery
no text
spDiscardOpp:OppChoose:2:Each opponent discards two cards.:Unnerve - opponent discards cards
Wheel and Deal
3 U
Instant
no text
spDiscardOpp:Hand:0:Drawback$OppDraw/7:Any number of target opponents each discards his or her hand and draws seven cards.:Wheel and Deal - target player discards cards
Draw a card.
Stupor
2 B
Sorcery
no text
spDiscardOpp:AtRandom:1:Drawback$OppDiscard/1:Target opponent discards a card at random, then discards a card.:Stupor - opponent discards cards
Mind Knives
1 B
Sorcery
no text
spDiscardOpp:AtRandom:1:Target opponent discards a card at random.:Mind Knives - opponent discards cards
Deception
2 B
Sorcery
no text
spDiscardOpp:OppChoose:2:Target opponent discards two cards.:Deception - opponent discards cards
Wit's End
5 B B
Sorcery
no text
spDiscardTgt:Hand:0:Target player discards his or her hand.:Wit's End - target player discards cards
Waking Nightmare
2 B
Sorcery Arcane
no text
spDiscardTgt:TgtChoose:2:Target player discards two cards.:Waking Nightmare - target player discards cards
Voices from the Void
4 B
Sorcery
no text
spDiscardTgt:TgtChoose:X:Domain - Target player discards a card for each basic land type among lands you control.:Voices from the Void - target player discards cards
Unhinge
2 B
Sorcery
no text
spDiscardTgt:TgtChoose:1:Target player discards a card.:Unhinge - target player discards a card
Draw a card.
Unburden
1 B B
Sorcery
no text
spDiscardTgt:TgtChoose:2:Target player discards two cards.:Unburden - target player discards cards
Cycling:2
Three Tragedies
3 B B
Sorcery Arcane
no text
spDiscardTgt:TgtChoose:3:Target player discards three cards.:Three Tragedies - target player discards cards
Specter's Wail
1 B
Sorcery
no text
spDiscardTgt:AtRandom:1:Target player discards a card at random.:Specter's Wail - target player discards a card
Mind Twist
X B
Sorcery
no text
spDiscardTgt:AtRandom:X:Target player discards X cards at random.:Mind Twist - target player discards cards
SVar:X:Count$xPaid
Mind Sludge
4 B
Sorcery
no text
spDiscardTgt:TgtChoose:X:Target player discards a card for each Swamp you control.:Mind Sludge - target player discards cards
SVar:X:Count$TypeYouCtrl.Swamp
Mind Shatter
X B B
Sorcery
spDiscardTgt:AtRandom:X:Target player discards X cards at random.:Mind Shatter - target player discards cards
SVar:X:Count$xPaid
Mind Rot
2 B
Sorcery
no text
spDiscardTgt:TgtChoose:2:Target player discards two cards.:Mind Rot - target player discards cards
Mind Peel
B
Sorcery
no text
spDiscardTgt:1:Target player discards a card.:Mind Peel - target player discards a card
SVar:Buyback:2 B B
Mind Burst
1 B
Sorcery
no text
spDiscardTgt:TgtChoose:X:Target player discards X cards, where X is one plus the number of cards named Mind Burst in all graveyards.:Mind Burst - target player discards cards
SVar:X:Count$NamedInAllYards.Mind Burst/Plus.1
Hymn to Tourach
B B
Sorcery
no text
spDiscardTgt:AtRandom:2:Target player discards two cards at random.:Hymn to Tourach - target player discards cards
Haunting Hymn
4 B B
Instant
no text
spDiscardTgt:TgtChoose:X:Target player discards two cards. If you cast this spell during your main phase, that player discards four cards instead.:Haunting Hymn - target player discards cards
SVar:X:Count$IfMainPhase.4.2
Fugue
3 B B
Sorcery
no text
spDiscardTgt:TgtChoose:3:Target player discards three cards.:Fugue - target player discards cards
Forget
U U
Sorcery
no text
spDiscardTgt:TgtChoose:2:Drawback$TgtDraw/2:Target player discards two cards, then draws as many cards as he or she discarded this way.:Forget - target player discards cards
Fill with Fright
3 B
Sorcery
no text
spDiscardTgt:TgtChoose:2:Target player discards two cards.:Fill with Fright - target player discards cards
Scry 2
Wrench Mind
B B
Sorcery
no text
spDiscardTgt:TgtChoose:2/UnlessDiscardType.Artifact:Target player discards two cards unless he or she discards an artifact card.:Wrench Mind - target player discards cards
Surging Dementia
1 B
Sorcery
no text
spDiscardTgt:TgtChoose:1:Target player discards a card.:Surging Dementia - Target player discards a card.
Ripple:4