Page 1 of 1

damage/combat damage events

PostPosted: 12 Feb 2010, 19:05
by mtgrares
I don't know would it be possible to add the methods below. (I don't mind doing the work but I'm just trying to figure out it is possible.)

Code: Select all
combatDamage(int nDamage, Card damageTo, Card damageFrom)
combatDamage(int nDamage, String player, Card damageFrom)

damage(int nDamage, String player, Card damageFrom)
damage(int nDamage, Card damageTo, Card damageFrom)
I know that damage is usually dealt by Card.addDamage(). A hacky solution would be something like this.

Code: Select all
 
Card class

public void addDamage(int n, Card source)
  {
     ...misc stuff for Cho-Manno, Revolutionary
    
     if (CardFactoryUtil.canDamage(source, this))
     {
        AllZone.GameAction.damage(n, this, source);
     }
  }
Dealing damage to a player could be implemented by doing to the same thing to PlayerLife.subtractLife(). And I think PlayerLife probably should have a damage() method added to it. Ooh the lovely design decisions that come back to haunt me, :lol:

GameAction has

Code: Select all
addDamage(Card card, Card source, int damage)
addDamage(Card card, HashMap<Card,Integer> map)

addLife(String player, int life)
subLife(String player, int life)
addDamage(String player, int damage)
but I don't know are they used everywhere (which they probably aren't.)

I know Forge does not have many "central points of control" and that is why Dennis had to re-write all of the targeting code to implement protection.

Just a few random thoughts. It is hard to know which thoughts are valuable and which one aren't. I just saw a History Detectives about Thomas Edison trying to build houses out of concrete, ha.

Re: damage/combat damage events

PostPosted: 13 Feb 2010, 03:03
by Rob Cashwalker
GameAction.addDamage is what most damage dealing effects SHOULD use. It's getting rather full, and I'm not sure how GameAction was intended to be used. It looked like it was a central repository for the player-neutral processing of the various standard effects - discard, damage, draw, life modification, etc. So, we've added a number of methods to GameAction that do basically the same thing, but with different inputs.

While I revised the abDamageCP code, I found that it was checking for lifelink effects, and three card-specific interactions and deathtouch. GameAction.addDamage had similar checks, but one was missing, I don't recall which one.

Basically, the goal should be to keep it all in one place for just this reason, so that if there absolutely must be hard-coded card interaction, that it's coded in one place, so that it affects all effects equally.

If GameAction was not intended to be such a repository, then by all means let's hammer out a plan for such a new class.

And yeah, combatDamage, directDamage and "anyDamage" need to be aggregated somehow. One of the card-specific interactions I had found implemented wrong, was Mirri, (the Cursed? I don't recall, I posted it in the bug thread, but that might've been before the hiccup) Mirri triggers off combat damage only, while the other card it was in an if-block for was any type of damage.

Re: damage/combat damage events

PostPosted: 19 Feb 2010, 19:38
by mtgrares
GameAction is a good place to put new methods, even though it might get crowed/complicated. At first GameAction just did basic stuff like draw a card but it seemed like a good place to put more complicated stuff like dealing damage and checking for state effects.

You (and Dennis, Chris, SillyFreak) have done a really good job grafting in new stuff. :)