spLoseLifeGainLife keyword
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
spLoseLifeGainLife keyword
by Chris H. » 18 Sep 2009, 18:02
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
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: spLoseLifeGainLife keyword
by Chris H. » 19 Sep 2009, 19:38
Abe submitted two cards which can use this keyword.
Add this to cards.txt:
Add this to cards-pictures.txt:
.

Add this to cards.txt:
- Code: Select all
Kiss of Death
4 B B
Sorcery
Kiss of Death deals 4 damage to target opponent. You gain 4 life.
spLoseLifeGainLife:4
Stolen Grain
4 B B
Sorcery
Stolen Grain deals 5 damage to target opponent. You gain 5 life.
spLoseLifeGainLife:5
Add this to cards-pictures.txt:
.
- Attachments
-
Abe two cards.zip
- (686 Bytes) Downloaded 420 times
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: spLoseLifeGainLife keyword
by Sloth » 19 Sep 2009, 20:25
Well you shouldn't be able to target yourself with Kiss of Death and Stolen Grain, but it's no big deal.
So if you accept this you can also add:
So if you accept this you can also add:
- Code: Select all
Vampiric Feast
4 B B
Sorcery
Vampiric Feast deals 4 damage to target opponent. You gain 4 life.
spLoseLifeGainLife:4
Vampiric Touch
2 B
Sorcery
Vampiric Touch deals 2 damage to target opponent and you gain 2 life.
spLoseLifeGainLife:2
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: spLoseLifeGainLife keyword
by Chris H. » 19 Sep 2009, 21:23
Rob mentioned that he planned at some point to do a life gaining keyword.Sloth wrote:Well you shouldn't be able to target yourself with Kiss of Death and Stolen Grain, but it's no big deal.
So if you accept this you can also add:

Rob, what do you think? Would you like to hold off on these 4 spells for now and add them at a later time?
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: spLoseLifeGainLife keyword
by Rob Cashwalker » 21 Sep 2009, 01:46
I'm working on an expanded damage spell which includes the "draw back" of gaining life.
Also, damage and loss of life need to be separate, because we may have effects that can trigger off damage.. or we might someday....
Also, damage and loss of life need to be separate, because we may have effects that can trigger off damage.. or we might someday....
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: spLoseLifeGainLife keyword
by silly freak » 21 Sep 2009, 09:43
i'd say we should have different methods for that, but can make them work the same (damage() calling loseLife() or such) as long as there's no difference. when there's a change, we don't have to track it in card factory
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: spLoseLifeGainLife keyword
by Chris H. » 21 Sep 2009, 10:24
While I was constructing the keyword, I wondered about the targeting issue. Soul Feast allows you to target yourself. I can't at this time come up for a reason to do this, but things could change at some point in the future.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: spLoseLifeGainLife keyword
by Rob Cashwalker » 21 Sep 2009, 17:59
I can revise it in the future when I apply some more abstraction to some existing keywords. Like the number of life on Tendrils of Corruption is a variable that I can calculate like in spDrawCards. I'm in the middle of tweaking some of that code into a generic CountX function that is to be reused in my revised spDamage code and multiple other places.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: spLoseLifeGainLife keyword
by Marek14 » 22 Sep 2009, 06:38
Mindslaver.Chris H. wrote:While I was constructing the keyword, I wondered about the targeting issue. Soul Feast allows you to target yourself. I can't at this time come up for a reason to do this, but things could change at some point in the future.
Re: spLoseLifeGainLife keyword
by Chris H. » 22 Sep 2009, 11:01
Yeah, that is an interesting card. It may be next to impossible to implement in Forge.Marek14 wrote:Mindslaver.

-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: spLoseLifeGainLife keyword
by Marek14 » 23 Sep 2009, 08:00
You know, people always say that, but is it really true? If a Human uses it, he just gains control of the decision - AI is off for one turn. If AI uses it, it's in complete control for one turn, can use your resources, but its goal is still to better itself.Chris H. wrote:Yeah, that is an interesting card. It may be next to impossible to implement in Forge.Marek14 wrote:Mindslaver.
Re: spLoseLifeGainLife keyword
by zerker2000 » 26 Sep 2009, 00:14
TranscendenceChris H. wrote:While I was constructing the keyword, I wondered about the targeting issue. Soul Feast allows you to target yourself. I can't at this time come up for a reason to do this, but things could change at some point in the future.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
- zerker2000
- Programmer
- Posts: 569
- Joined: 09 May 2009, 21:40
- Location: South Pasadena, CA
- Has thanked: 0 time
- Been thanked: 0 time
Re: spLoseLifeGainLife keyword
by Chris H. » 13 Dec 2009, 19:47
I have discovered a problem with this keyword and the new spell Absorb Vis. The spLoseLifeGainLife keyword does not contain code to create the card description and uses the text from cards.txt.
As such, when you cast Absorb Vis you are not given a choice between the spell and cycling. In fact, the cycling ability is completed ignored. This is my fault. I can only plead ignorance as I am still learning how to code at this time.
I am now trying to fix the spLoseLifeGainLife keyword so that it will work correctly in this fashion. This in turn brings up a second issue.
Currently, the spells Kiss of Death; Stolen Grain and Vampiric Touch use the spLoseLifeGainLife keyword. I think that they should be removed from the spLoseLifeGainLife keyword code base.
There are two options that I am considering. One would be to make a few mods to the spLoseLifeGainLife keyword and create a spOppDamGainLife keyword. Or Rob's spDamageTgt keyword code code be changed to allow a spDamageTgtOpp variant.
As such, when you cast Absorb Vis you are not given a choice between the spell and cycling. In fact, the cycling ability is completed ignored. This is my fault. I can only plead ignorance as I am still learning how to code at this time.

I am now trying to fix the spLoseLifeGainLife keyword so that it will work correctly in this fashion. This in turn brings up a second issue.
Currently, the spells Kiss of Death; Stolen Grain and Vampiric Touch use the spLoseLifeGainLife keyword. I think that they should be removed from the spLoseLifeGainLife keyword code base.
There are two options that I am considering. One would be to make a few mods to the spLoseLifeGainLife keyword and create a spOppDamGainLife keyword. Or Rob's spDamageTgt keyword code code be changed to allow a spDamageTgtOpp variant.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
18 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 16 guests