Ordering of static effects
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
3 posts
• Page 1 of 1
Ordering of static effects
by Sloth » 23 Jun 2011, 21:02
There were some bug reports concerning Lignify played on a card that granted a static pump effect. The problem lies in the ordering of static effects. Here is what's happening in checkStateEffects:
1. stAnimate effects get removed
2. stAnimate effects get added
3. stSetPT effects get removed
4. stSetPT effects get added
5. stPump effects get removed
6. stPump effects get added
The problem is when checkStateEffects is called the first time after Lignify was cast. Lignify removes all keywords from the enchanted card in step 2, but the information is needed in step 5 to remove the old stPump effect.
My quick solution is to reorder the effects to:
1. stAnimate effects get removed
3. stSetPT effects get removed
5. stPump effects get removed
2. stAnimate effects get added
4. stSetPT effects get added
6. stPump effects get added
But maybe we can discuss improving the whole system to be closer to the layer system or to improve the performance (someone reported slow downs caused by static effects).
1. stAnimate effects get removed
2. stAnimate effects get added
3. stSetPT effects get removed
4. stSetPT effects get added
5. stPump effects get removed
6. stPump effects get added
The problem is when checkStateEffects is called the first time after Lignify was cast. Lignify removes all keywords from the enchanted card in step 2, but the information is needed in step 5 to remove the old stPump effect.
My quick solution is to reorder the effects to:
1. stAnimate effects get removed
3. stSetPT effects get removed
5. stPump effects get removed
2. stAnimate effects get added
4. stSetPT effects get added
6. stPump effects get added
But maybe we can discuss improving the whole system to be closer to the layer system or to improve the performance (someone reported slow downs caused by static effects).
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Ordering of static effects
by Braids » 24 Jun 2011, 01:44
if my familiarity with the official rules serves correct, this sort of thing is applied in timestamp order. does that help?
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 
-

Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: Ordering of static effects
by Sloth » 24 Jun 2011, 06:40
Actually it's a wild mix of layers, dependencies and lastly timestamps that define the ordering.Braids wrote:if my familiarity with the official rules serves correct, this sort of thing is applied in timestamp order. does that help?
Another thing that's easy to do, to speed things up:
At the moment everything is checked twice in checkStateEffects which is correct sometimes, but only if the gamestate is changed by a static effect. I will add a boolean "checkAgain" that is turned true if something is destroyed or unequipped and if nothing happens static effects won't be checked again. This should almost half the time used up by checkStateEffects.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 25 guests