It is currently 08 Sep 2025, 12:04
   
Text Size

two addDamage methods?

Post MTG Forge Related Programming Questions Here

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

two addDamage methods?

Postby DennisBergkamp » 06 Sep 2010, 06:18

Is there any reason we have these two addDamage methods in GameAction?

Code: Select all
public void addDamage(String player, int damage, Card source) {
        // place holder for future damage modification rules (prevention?)
       
       if(source.getKeyword().contains("Lifelink")) GameActionUtil.executeLifeLinkEffects(source, damage);
       
       CardList cl = CardFactoryUtil.getAurasEnchanting(source, "Guilty Conscience");
        for(Card c:cl) {
            GameActionUtil.executeGuiltyConscienceEffects(source, c, damage);
        }
        getPlayerLife(player).subtractLife(damage,source);
    }
    /**
    public void addDamage(String player, int damage) {
        // place holder for future damage modification rules (prevention?)
       
        getPlayerLife(player).subtractLife(damage);
    }
    **/
    public void addDamage(String player, Card source, int damage) {
        getPlayerLife(player).subtractLife(damage,source);
       
        if(source.getKeyword().contains("Lifelink")) GameActionUtil.executeLifeLinkEffects(source, damage);
       
        CardList cl = CardFactoryUtil.getAurasEnchanting(source, "Guilty Conscience");
        for(Card c:cl) {
            GameActionUtil.executeGuiltyConscienceEffects(source, c, damage);
        }
       
    }
The only difference is that the parameters taken are reversed, and for the first one life gets subtracted after checking for lifelink/Guilty Conscience, for the second one it happens before...
Unless I'm missing something here, I think it should be safe for me to turn these into one single method?
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: two addDamage methods?

Postby DennisBergkamp » 06 Sep 2010, 07:46

Never mind, it was obvious this second method was unnecessary. I got rid of it and made a bunch of other changes that should increase flexibility of the damage code. Might even allow for coding some new cards :mrgreen:

By the way, I couldn't resist and started adding some of the new spoiled cards... cool thing is, that all of the new stuff seems to be very doable in Forge (Proliferate, Infect, Emblems, Metalcraft), even both Planeswalkers look like a piece of cake.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: two addDamage methods?

Postby Sloth » 09 Sep 2010, 07:30

DennisBergkamp wrote:By the way, I couldn't resist and started adding some of the new spoiled cards... cool thing is, that all of the new stuff seems to be very doable in Forge (Proliferate, Infect, Emblems, Metalcraft), even both Planeswalkers look like a piece of cake.
Did you implement the new keyword Infect to also work with non-combat damage, because Wither and "Whenever a creature dealt damage by CARDNAME this turn is put into a graveyard, put a +1/+1 counter on CARDNAME." do not.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: two addDamage methods?

Postby DennisBergkamp » 09 Sep 2010, 17:34

Yes, I'm pretty sure Infect also works for ping-effects... but so should Wither, if I'm not mistaken.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: two addDamage methods?

Postby Sloth » 09 Sep 2010, 19:03

DennisBergkamp wrote:Yes, I'm pretty sure Infect also works for ping-effects... but so should Wither, if I'm not mistaken.
You're right Wither works for pingers (I tested with Pestilence Demon were it did not work, but this should be a problem of the Demon, not with Wither).
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: two addDamage methods?

Postby DennisBergkamp » 09 Sep 2010, 19:04

Ah, I'll look into the Demon.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 54 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 54 users online :: 0 registered, 0 hidden and 54 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 54 guests

Login Form