It is currently 26 Apr 2024, 15:36
   
Text Size

spLoseLifeGainLife keyword

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

spLoseLifeGainLife keyword

Postby 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:

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
User avatar
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

Postby Chris H. » 19 Sep 2009, 19:38

Abe submitted two cards which can use this keyword. :)

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 390 times
User avatar
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

Postby 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:

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
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: spLoseLifeGainLife keyword

Postby mtgrares » 19 Sep 2009, 20:31

Thanks for the code. :)
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: spLoseLifeGainLife keyword

Postby Chris H. » 19 Sep 2009, 21:23

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 mentioned that he planned at some point to do a life gaining keyword. :-k I wonder if this future keyword would have a parameter to handle these spells.

Rob, what do you think? Would you like to hold off on these 4 spells for now and add them at a later time?
User avatar
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

Postby 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....
The Force will be with you, Always.
User avatar
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

Postby 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!
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

Postby 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.
User avatar
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

Postby 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.
User avatar
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

Postby Marek14 » 22 Sep 2009, 06:38

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.
Mindslaver.
Marek14
Tester
 
Posts: 2761
Joined: 07 Jun 2008, 07:54
Has thanked: 0 time
Been thanked: 297 times

Re: spLoseLifeGainLife keyword

Postby Chris H. » 22 Sep 2009, 11:01

Marek14 wrote:Mindslaver.
Yeah, that is an interesting card. It may be next to impossible to implement in Forge. :)
User avatar
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

Postby Marek14 » 23 Sep 2009, 08:00

Chris H. wrote:
Marek14 wrote:Mindslaver.
Yeah, that is an interesting card. It may be next to impossible to implement in Forge. :)
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.
Marek14
Tester
 
Posts: 2761
Joined: 07 Jun 2008, 07:54
Has thanked: 0 time
Been thanked: 297 times

Re: spLoseLifeGainLife keyword

Postby zerker2000 » 26 Sep 2009, 00:14

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.
Transcendence
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
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

Postby Marek14 » 26 Sep 2009, 16:26

And, of course, Deflection.
Marek14
Tester
 
Posts: 2761
Joined: 07 Jun 2008, 07:54
Has thanked: 0 time
Been thanked: 297 times

Re: spLoseLifeGainLife keyword

Postby 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. :oops:

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.
User avatar
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

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 115 guests


Who is online

In total there are 115 users online :: 0 registered, 0 hidden and 115 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 115 guests

Login Form