spLoseLife[Tgt] keyword

As I looked at revising Chris' spLoseLifeGainLife keyword, I found that there were very few additional cards that lose life AND gain life. But there were a couple extra cards that could be done that just cause loss of life. The Drawback$ functionality easily adds the gain life effect to those cards that need it.
So, here's the syntax:
Yes, Tgt is optional, because the keyword can support Stronghold Discipline. So far, it's the only one, but it's always nice to be flexible.
Existing cards:
So, here's the syntax:
- Code: Select all
spLoseLife{Tgt}:NumLife:{Drawback}:{SpellDescription}:{StackDescription}
Yes, Tgt is optional, because the keyword can support Stronghold Discipline. So far, it's the only one, but it's always nice to be flexible.
Existing cards:
- Code: Select all
Absorb Vis
6 B
Sorcery
no text
spLoseLifeTgt:4:Drawback$YouGainLife/4:Target player loses 4 life and you gain 4 life.
TypeCycling:Basic:1 B
Last Caress
2 B
Sorcery
no text
spLoseLifeTgt:1:Drawback$YouGainLife/1:Target player loses 1 life and you gain 1 life.
Draw a card.
Soul Feast
3 B B
Sorcery
no text
spLoseLifeTgt:4:Drawback$YouGainLife/4:Target player loses 4 life and you gain 4 life.
Morsel Theft
2 B B
Tribal Sorcery Rogue
(NOTE: "Prowl" is not implemented.)
spLoseLifeTgt:3:Drawback$YouGainLife/3:Target player loses 3 life and you gain 3 life.:Morsel Theft - target player loses life and you gain life
- Code: Select all
Exotic Disease
4 B
Sorcery
no text
spLoseLifeTgt:X:Drawback$YouGainLife/X:Domain - Target player loses X life and you gain X life, where X is the number of basic land types among lands you control.
SVar:X:Count$Domain
Stronghold Discipline
2 B B
Sorcery
no text
spLoseLife:X:Drawback$OppLoseLife/dX:Each player loses 1 life for each creature he or she controls.:Stronghold Discipline - each player loses life
SVar:X:Count$TypeYouCtrl.Creature
SVar:dX:Count$TypeOppCtrl.Creature
Syphon Life
1 B B
Sorcery
(NOTE: "Retrace" is not implemented.)
spLoseLifeTgt:2:Drawback$YouGainLife/2:Target player loses 2 life and you gain 2 life.:Syphone Life - target player loses life and you gain life
- Code: Select all
if (hasKeyword(card, "spLoseLife") != -1)
{
int n = hasKeyword(card, "spLoseLife");
if (n != -1)
{
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 NumLife[] = {-1};
final String NumLifeX[] = {"none"};
if (k[1].matches("X"))
{
String x = card.getSVar(k[1]);
if (x.startsWith("Count$"))
{
String kk[] = x.split("\\$");
NumLifeX[0] = kk[1];
}
}
else if (k[1].matches("[0-9][0-9]?"))
NumLife[0] = Integer.parseInt(k[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];
}
}
else
{
if (Tgt[0] == true)
{
spDesc[0] = "Target player loses " + NumLife[0] + " life.";
stDesc[0] = cardName + " - target player loses life";
}
else
{
spDesc[0] = "You lose " + NumLife[0] + " life.";
stDesc[0] = cardName + " - you lose life";
}
}
final SpellAbility spLoseLife = new Spell(card)
{
private static final long serialVersionUID = -8361697584661592092L;
public int getNumLife()
{
if (NumLife[0] != -1)
return NumLife[0];
if (! NumLifeX[0].equals("none"))
return CardFactoryUtil.xCount(card, NumLifeX[0]);
return 0;
}
public boolean canPlayAI()
{
if (Tgt[0] == true)
{
setTargetPlayer(Constant.Player.Human);
return true;
}
else // pretty much just for Stronghold Discipline...
{ // assumes there's a good Drawback$ that makes losing life worth it
int nlife = getNumLife();
if ((AllZone.Computer_Life.getLife() - nlife) > 10)
return true;
else
return false;
}
}
public void resolve()
{
int nlife = getNumLife();
String TgtPlayer;
if (Tgt[0] == true)
TgtPlayer = getTargetPlayer();
else
TgtPlayer = card.getController();
AllZone.GameAction.subLife(TgtPlayer, nlife);
if (!DrawBack[0].equals("none"))
CardFactoryUtil.doDrawBack(DrawBack[0], nlife, card.getController(), AllZone.GameAction.getOpponent(card.getController()), TgtPlayer, card, null);
}//resolve()
};//SpellAbility
if (Tgt[0] == true)
spLoseLife.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spLoseLife));
spLoseLife.setDescription(spDesc[0]);
spLoseLife.setStackDescription(stDesc[0]);
card.clearSpellAbility();
card.addSpellAbility(spLoseLife);
}
}
- Code: Select all
if (condition) {
...
}
- Code: Select all
if (condition)
{
...
}