spDrawCards v2

Basically a revision of existing spDrawCards keyword that takes the same advanced syntax as the recent spDamageTgt keyword.
CardFactory.java
CardFactory.java
- Code: Select all
if (shouldSpDrawCards(card) != -1)
{
int n = shouldSpDrawCards(card);
String parse = card.getKeyword().get(n).toString();
card.removeIntrinsicKeyword(parse);
String k[] = parse.split(":");
final boolean Tgt[] = {false};
Tgt[0] = k[0].contains("Tgt");
final int NumCards[] = {-1};
final String NumCardsX[] = {"none"};
if (k[1].length() <= 2)
NumCards[0] = Integer.parseInt(k[1]);
else
{
if (k[1].startsWith("Count$"))
{
String kk[] = k[1].split("\\$");
NumCardsX[0] = kk[1];
}
}
// drawbacks and descriptions
final String DrawBack[] = {"none"};
final String spDesc[] = {"none"};
final String stDesc[] = {"none"};
if (k.length > 2)
{
if (k[2].contains("Drawback$"))
{
String kk[] = k[2].split("\\$");
DrawBack[0] = kk[1];
if (k.length > 3)
spDesc[0] = k[3];
if (k.length > 4)
stDesc[0] = k[4];
}
else
{
if (k.length > 2)
spDesc[0] = k[2];
if (k.length > 3)
stDesc[0] = k[3];
}
}
final SpellAbility spDraw = new Spell(card)
{
private static final long serialVersionUID = -7049779241008089696L;
private int ncards;
public int getNumCards()
{
if (NumCards[0] != -1)
return NumCards[0];
if (! NumCardsX[0].equals("none"))
return CardFactoryUtil.xCount(card, NumCardsX[0]);
return 0;
}
public boolean canPlayAI()
{
ncards = getNumCards();
int h = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer).size();
int hl = AllZone.getZone(Constant.Zone.Library, Constant.Player.Human).size();
int cl = AllZone.getZone(Constant.Zone.Library, Constant.Player.Computer).size();
Random r = new Random();
if (((hl - ncards) < 2) && Tgt[0])
{
setTargetPlayer(Constant.Player.Computer);
return true;
}
if (((h + ncards) <= 7) && !((cl - ncards) < 1) && (r.nextInt(10) > 4))
{
setTargetPlayer(Constant.Player.Computer);
return true;
}
return false;
}
public void resolve()
{
ncards = getNumCards();
String TgtPlayer = card.getController();
if (Tgt[0])
TgtPlayer = getTargetPlayer();
for (int i=0; i < ncards; i++)
AllZone.GameAction.drawCard(TgtPlayer);
if (! DrawBack[0].equals("none"))
CardFactoryUtil.doDrawBack(DrawBack[0], ncards, card.getController(), AllZone.GameAction.getOpponent(card.getController()), TgtPlayer, card, null);
}
};
if (Tgt[0])
spDraw.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spDraw));
if (! spDesc[0].equals("none"))
spDraw.setDescription(spDesc[0]);
else
spDraw.setDescription("Draw " + NumCards[0] + " cards.");
if (! stDesc[0].equals("none"))
spDraw.setStackDescription(stDesc[0]);
else
spDraw.setStackDescription("You draw " + NumCards[0] + " cards.");
card.clearSpellAbility();
card.addSpellAbility(spDraw);
}//spDrawCards
- Code: Select all
Night's Whisper
1 B
Sorcery
no text
spDrawCards:2:Drawback$YouLoseLife/2:You draw two cards and you lose 2 life.:Night's Whisper - draw 2 cards and lose 2 life.
Words of Wisdom
1 U
Instant
no text
spDrawCards:2:Drawback$OppDraw/1:You draw two cards, then each other player draws a card.:Words of Wisdom - draw 2 cards and opponent draws 1 card.
Counsel of the Soratami
2 U
Sorcery
no text
spDrawCards:2:Draw two cards.:Counsel of the Soratami - draw 2 cards.
Touch of Brilliance
3 U
Sorcery
no text
spDrawCards:2:Draw two cards.:Touch of Brilliance - draw 2 cards.
Inspiration
3 U
Sorcery
no text
spDrawCards:2:Draw two cards.:Inspiration - draw 2 cards.
Concentrate
2 U U
Sorcery
no text
spDrawCards:3:Draw three cards.:Concentrate - draw 3 cards.
Harmonize
2 G G
Sorcery
no text
spDrawCards:3:Draw three cards.:Harmonize - draw 3 cards.
Ancestral Recall
U
Instant
no text
spDrawCardsTgt:3:Target player draws three cards.:Ancestral Recall - draw 3 cards.
Minions' Murmurs
2 B B
Sorcery
no text
spDrawCards:Count$TypeYouCtrl.Creature:Drawback$YouLoseLife/X:You draw X cards and you lose X life, where X is the number of creatures you control.:Minion's Murmurs - draw cards and lose life.
Brainstorm
U
Instant
no text
spDrawCards:3:Drawback$YouHandToLibrary/2/Top:Draw three cards, then put two cards from your hand on top of your library in any order.:Brainstorm - draw 3 cards and put 2 on top of your library.
- Code: Select all
Airborne Aid
3 U
Sorcery
no text
spDrawCards:Count$TypeOnBattlefield.Bird:Draw a card for each Bird on the battlefield.:Airborne Aid - draw cards.
Borrowing 100,000 Arrows
2 U
Sorcery
no text
spDrawCards:Count$TappedTypeOppCtrl.Creature:Draw a card for each tapped creature target opponent controls.:Borrowing 100,000 Arrows - draw cards.
Collective Unconscious
4 G G
Sorcery
no text
spDrawCards:Count$TypeYouCtrl.Creature:Draw a card for each creature you control.:Collective Unconscious - draw cards.