Page 1 of 1

two addDamage methods?

PostPosted: 06 Sep 2010, 06:18
by DennisBergkamp
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?

Re: two addDamage methods?

PostPosted: 06 Sep 2010, 07:46
by DennisBergkamp
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.

Re: two addDamage methods?

PostPosted: 09 Sep 2010, 07:30
by Sloth
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.

Re: two addDamage methods?

PostPosted: 09 Sep 2010, 17:34
by DennisBergkamp
Yes, I'm pretty sure Infect also works for ping-effects... but so should Wither, if I'm not mistaken.

Re: two addDamage methods?

PostPosted: 09 Sep 2010, 19:03
by Sloth
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).

Re: two addDamage methods?

PostPosted: 09 Sep 2010, 19:04
by DennisBergkamp
Ah, I'll look into the Demon.