It is currently 11 Sep 2025, 16:20
   
Text Size

damage/combat damage events

Post MTG Forge Related Programming Questions Here

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

damage/combat damage events

Postby mtgrares » 12 Feb 2010, 19:05

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.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: damage/combat damage events

Postby Rob Cashwalker » 13 Feb 2010, 03:03

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.
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: damage/combat damage events

Postby mtgrares » 19 Feb 2010, 19:38

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. :)
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 35 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 35 users online :: 0 registered, 0 hidden and 35 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 35 guests

Login Form