It is currently 29 Oct 2025, 21:26
   
Text Size

Ordering of static effects

Post MTG Forge Related Programming Questions Here

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

Ordering of static effects

Postby 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).
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Ordering of static effects

Postby 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. ;)
User avatar
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

Postby Sloth » 24 Jun 2011, 06:40

Braids wrote:if my familiarity with the official rules serves correct, this sort of thing is applied in timestamp order. does that help?
Actually it's a wild mix of layers, dependencies and lastly timestamps that define the ordering.

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 25 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 25 users online :: 0 registered, 0 hidden and 25 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 25 guests

Login Form