spLoseLifeGainLife keyword

A new keyword, spLoseLifeGainLife. It uses the form:
spLoseLifeGainLife:{num}
I converted the spells Last Caress, Morsel Theft and Soul Feast to use these new keyword. I tested all three cards and they work. The code built without any errors or warnings. I think it is ready.
This code is added to CardFactory.java with the other code which checks for a matching keyword:
This code is added to CardFactory.java with the other code which creates the spell abilities for the keyword cards:
The original code for these spells can be commented out fairly easily:
The card entries for these three cards located in cards.txt will need to be changed:
spLoseLifeGainLife:{num}
I converted the spells Last Caress, Morsel Theft and Soul Feast to use these new keyword. I tested all three cards and they work. The code built without any errors or warnings. I think it is ready.
This code is added to CardFactory.java with the other code which checks for a matching keyword:
- Code: Select all
// spLoseLifeGainLife
private final int shouldSpLoseLifeGainLife(Card c){
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("spLoseLifeGainLife"))
return i;
return -1;
}
This code is added to CardFactory.java with the other code which creates the spell abilities for the keyword cards:
- Code: Select all
//Spell gain life lose life cards (like Soul Feast)
if (shouldSpLoseLifeGainLife(card) != -1)
{
int n = shouldSpLoseLifeGainLife(card);
if (n != -1)
{
String parse = card.getKeyword().get(n).toString();
card.removeIntrinsicKeyword(parse);
card.clearSpellAbility();
String k[] = parse.split(":");
final String lfdmg = k[1];
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = -8277174319360648715L;
public void resolve()
{
final int n = Integer.parseInt(lfdmg);
AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(n);
PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
life.addLife(n);
}//resolve()
};//SpellAbility
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
return card;
}
}// spLoseLifeGainLife
The original code for these spells can be commented out fairly easily:
- Code: Select all
/*
////////////////////////////////////////////////////////////
if (cardName.equals("Soul Feast") || cardName.equals("Last Caress"))
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = -8277174319360648715L;
public void resolve()
{
int n = 4;
if (cardName.equals("Last Caress"))
n = 1;
AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(n);
PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
life.addLife(n);
}//resolve()
};//SpellAbility
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
return card;
}
//////////////////////////////////////////////////////////
*/
/*
////////////////////////////////////////////////////////////
if(cardName.equals("Morsel Theft")) // missing Prowl
{
final SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = -6361475064894444152L;
public void resolve()
{
int n = 3;
AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(n);
PlayerLife life = AllZone.GameAction.getPlayerLife(card.getController());
life.addLife(n);
}//resolve()
};//SpellAbility
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
return card;
}
//////////////////////////////////////////////////////////
*/
The card entries for these three cards located in cards.txt will need to be changed:
- Code: Select all
Last Caress
2 B
Sorcery
Target player loses 1 life and you gain 1 life. Draw a card.
spLoseLifeGainLife:1
Cantrip
Morsel Theft
2 B B
Sorcery
Target player loses 3 life and you gain 3 life. (NOTE: "Prowl" is not implemented.)
spLoseLifeGainLife:3
Soul Feast
3 B B
Sorcery
Target player loses 4 life and you gain 4 life.
spLoseLifeGainLife:4