Page 1 of 1

Damage prevention shields with effects

PostPosted: 28 Jun 2013, 17:00
by moomarc
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.

Re: Damage prevention shields with effects

PostPosted: 28 Jun 2013, 20:04
by Max mtg
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.

Re: Damage prevention shields with effects

PostPosted: 28 Jun 2013, 20:44
by Sloth
Max mtg wrote:This appears to prove that the current damage assignment implementation (right from effect executor) is completelly incorrect.
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).

Re: Damage prevention shields with effects

PostPosted: 29 Jun 2013, 11:31
by moomarc
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.

Re: Damage prevention shields with effects

PostPosted: 29 Jun 2013, 11:42
by Max mtg
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.
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

Re: Damage prevention shields with effects

PostPosted: 29 Jun 2013, 11:50
by Sloth
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.
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.

Re: Damage prevention shields with effects

PostPosted: 29 Jun 2013, 12:41
by moomarc
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
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) :mrgreen:

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.
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.

Re: Damage prevention shields with effects

PostPosted: 29 Jun 2013, 14:59
by Max mtg
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

Re: Damage prevention shields with effects

PostPosted: 29 Jun 2013, 18:54
by moomarc
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.