Damage prevention shields with effects
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
9 posts
• Page 1 of 1
Damage prevention shields with effects
by moomarc » 28 Jun 2013, 17:00
r22321: I've just committed some code to allow damage prevention shields to have related effects for cards like Temper and Vengeful Archon (also these). I also added all the cards in that list except for the two modern/extended cards. Hopefully one of you guys can work out how to expand what I did to make those possible. Essentially it should be the difference between PreventDamage and PreventDamageAll, but I don't think PreventDamageAll is actually set up the way it should be. Currently it gives X damage prevention shields to all valid entities rather than one common one, thereby preventing more damage than it should. Probably need to add a "CommonShield" boolean to the shields, then if that shield is decreased, decrease it on all entities with that shield. Havent quite got it straight in my head yet which is why I haven't implemented.
Edit: I also have to add the two with delayed triggers but ran out of time.
Edit 2: I left the debug code in but disabled the boolean controlling it. Re-enable at ln891 in Player.java or ln7345 in Card.java for further testing or expansion.
Edit: I also have to add the two with delayed triggers but ran out of time.
Edit 2: I left the debug code in but disabled the boolean controlling it. Re-enable at ln891 in Player.java or ln7345 in Card.java for further testing or expansion.
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Damage prevention shields with effects
by Max mtg » 28 Jun 2013, 20:04
There's a test case that I couldn't solve thinking of the prevention effects.
Alice has 3 bears, Bob casts Pyroclasm, in resonse Alice casts Divine Deflection for 3. Will she be able to prevent 1 damage from each bear and thus save them all in Forge?
This appears to prove that the current damage assignment implementation (right from effect executor) is completelly incorrect.
Alice has 3 bears, Bob casts Pyroclasm, in resonse Alice casts Divine Deflection for 3. Will she be able to prevent 1 damage from each bear and thus save them all in Forge?
This appears to prove that the current damage assignment implementation (right from effect executor) is completelly incorrect.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Damage prevention shields with effects
by Sloth » 28 Jun 2013, 20:44
You are right, there should be a function in GameAction that handles all damage dealing. It would need to be passed a damage assignment map (complete with sources, victims and amounts).Max mtg wrote:This appears to prove that the current damage assignment implementation (right from effect executor) is completelly incorrect.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Damage prevention shields with effects
by moomarc » 29 Jun 2013, 11:31
Trying to get Sacred Boon and Scars of the Veteran working is turning out to be a pain. I can't figure out how to replace the "PreventedDamage" and "ShieldEffectTarget" strings on the delayed ability which it looks on the source card for. I can't replace the original string on the source card though because future activations would be broken then. Any ideas?
When the shield is used it could add svar:PreventedDamage:Number$<damage prevented> but that would still leave the Defined target broken.
When the shield is used it could add svar:PreventedDamage:Number$<damage prevented> but that would still leave the Defined target broken.
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Damage prevention shields with effects
by Max mtg » 29 Jun 2013, 11:42
Cast some Divine Deflection from hand, then return spell from grave to hand and cast it again with a different x. To avoid bugs here we must not use any svar from source card, nor associated ability. Prevention shild has to be a new object, listing objects it can protect and the damage remaining in the shield. This will also render useless that numeric filed in gameentity - damagetoprevent or something like thatmoomarc wrote:Trying to get Sacred Boon and Scars of the Veteran working is turning out to be a pain. I can't figure out how to replace the "PreventedDamage" and "ShieldEffectTarget" strings on the delayed ability which it looks on the source card for. I can't replace the original string on the source card though because future activations would be broken then. Any ideas?
When the shield is used it could add svar:PreventedDamage:Number$<damage prevented> but that would still leave the Defined target broken.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Damage prevention shields with effects
by Sloth » 29 Jun 2013, 11:50
What about creating an Effect that holds the trigger and stores the Svar?moomarc wrote:Trying to get Sacred Boon and Scars of the Veteran working is turning out to be a pain. I can't figure out how to replace the "PreventedDamage" and "ShieldEffectTarget" strings on the delayed ability which it looks on the source card for. I can't replace the original string on the source card though because future activations would be broken then. Any ideas?
When the shield is used it could add svar:PreventedDamage:Number$<damage prevented> but that would still leave the Defined target broken.
Delayed Triggers don't have to use the DelayedTrigger API i think.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Damage prevention shields with effects
by moomarc » 29 Jun 2013, 12:41
I considered making the shields a new object class that worked the way you suggest, but it is a bit beyond my ability so I implemented what I could manage. Sometimes someone has to take the baby steps that opens the door for someone better to improve it (overhauling damage assignment and prevention/redirection in this case)Max mtg wrote:Cast some Divine Deflection from hand, then return spell from grave to hand and cast it again with a different x. To avoid bugs here we must not use any svar from source card, nor associated ability. Prevention shild has to be a new object, listing objects it can protect and the damage remaining in the shield. This will also render useless that numeric filed in gameentity - damagetoprevent or something like that

That might just work. Should just need to pass the extra svars through via the shield instead of trying to handle it through the Effect API's adding of svars. Then I could do the string replacements en-route. Thanks.Sloth wrote:What about creating an Effect that holds the trigger and stores the Svar?
Delayed Triggers don't have to use the DelayedTrigger API i think.
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Damage prevention shields with effects
by Max mtg » 29 Jun 2013, 14:59
Effect - yes, an effect to apply to remembered of defined cards would be good.
But looks like that would lead you to code duplication in scripts. It could be fine to create an effect right from executor code
But looks like that would lead you to code duplication in scripts. It could be fine to create an effect right from executor code
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Damage prevention shields with effects
by moomarc » 29 Jun 2013, 18:54
Added Sacred Boon and Scars of the Veteran with some small changes in r22331. Still nowhere near implementing Refraction Trap or Divine Deflection though, unfortunately.
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 54 guests