It is currently 29 Oct 2025, 19:23
   
Text Size

LeavesPlayCommand not working

Post MTG Forge Related Programming Questions Here

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

LeavesPlayCommand not working

Postby Sloth » 22 May 2011, 08:19

It seems to me that all LeavesPlayCommand aren't working any more. All the reports concerning auras not unenchanting when leaving the battlefield are result of this. I also tested other cards like Lightning Crafter and their LeavesPlayCommand won't happen.

I tried to look into how it works, but the code is all over the place. Can anyone else try to fix this?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: LeavesPlayCommand not working

Postby friarsol » 22 May 2011, 13:49

Yea this is an important bug that needs to be fixed. It'd be nice to know about when it broke, so we can hunt down the changes that broke it and get the code fixed.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: LeavesPlayCommand not working

Postby Hellfish » 22 May 2011, 14:41

I just tested Turn to Slag ing a Lightning Crafter that championed an Akki Avalancher and is enchanted with AEther Web. I put a breakpoint in Card.leavesPlay() and found that leavesPlay commands *are* run, but Lightning Crafter doesn't return the championed creature because it tries to get the target from it's first ability (Comes Into Play championing) but only gets null.The AEther Web correctly falls off the Lightning Crafter and subsequently goes to the graveyard. So that sucks, apparently only some auras are affected. :|

Lightning Crafter is missing it's championing rules text,btw.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: LeavesPlayCommand not working

Postby friarsol » 22 May 2011, 14:45

Looks like this is in GameAction in the moveTo functions. I'll try to rewrite this block to work properly. If I can get LastKnownInfo working at the same time that'll be awesome, but otherwise I'll be content with getting Auras working.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: LeavesPlayCommand not working

Postby friarsol » 22 May 2011, 15:07

Ok, I just rewrote this whole function and my Auratog was properly losing its pump from Rancor. I also changed the ordering about when the Triggers happen, and tested with Altar of Dementia in the same deck. I believe Last Known Info works properly now, but I'd like more testing before declaring that the case. Can someone retest the Champion thing? But I think all should be working now.

Hellfish, it looks like when I sacrifice my Rancor to my Auratog, the Rancor's effect wasn't being placed on the stack until after the Auratog ability resolved (instead of after it hit the stack). Seems related to the Forbidden Orchard problem I noticed the other day. I'm guessing when something is being added to the stack, the triggers aren't being flushed properly? This might be an easier test case for you to debug the issue with.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: LeavesPlayCommand not working

Postby friarsol » 22 May 2011, 15:48

Ok and r8908 has a bugfix for not copying tokens, and actually copying when cards change zones, instead of copying when cards stay in the same zone.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: LeavesPlayCommand not working

Postby Sloth » 22 May 2011, 15:49

I would have been happy if one of the most reported bugs would have been fixed, but fixing both at the same time is just great! Thumbs up Sol!

I did test Holy Strength with Disenchant, Glorious Anthem with Diamond Valley and Lightning Crafter. Everything worked as expected.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: LeavesPlayCommand not working

Postby Hellfish » 22 May 2011, 16:55

The problem with some triggers not going on the stack when they should is related to when priority is passed (As that's currently the only time simultaneous triggers are flushed, which AFAIU is correct). I'm trying to stay as authentic as possible with this, but worst case scenario I'll simply manually flush simultaneous triggers at certain extra points.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: LeavesPlayCommand not working

Postby friarsol » 22 May 2011, 16:59

Hellfish wrote:The problem with some triggers not going on the stack when they should is related to when priority is passed (As that's currently the only time simultaneous triggers are flushed, which AFAIU is correct). I'm trying to stay as authentic as possible with this, but worst case scenario I'll simply manually flush simultaneous triggers at certain extra points.
Ahhh interesting. Priority isn't passed when a player activates an ability (they hold onto Priority) and when Priority passes to the AI they (usually) pass it right back to resolve the ability faster than the Triggers can hit the Stack. Sounds like we need a flush right in MagicStack.AddAndUnfreezeStack (or whatever my awesome naming convention was)
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: LeavesPlayCommand not working

Postby Hellfish » 23 May 2011, 06:36

I've tried manually flushing the simultaneous triggers in various places around the stack code without success (including both add() methods,addAndUnfreeze() and unfreezeStack()). Once I get some time, I'll step through the entire process to get a better eye for things.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: LeavesPlayCommand not working

Postby friarsol » 23 May 2011, 11:57

Hellfish wrote:I've tried manually flushing the simultaneous triggers in various places around the stack code without success (including both add() methods,addAndUnfreeze() and unfreezeStack()). Once I get some time, I'll step through the entire process to get a better eye for things.
Yea one of the things I sorta need to do before I can fix the targeting issues is centralize all of these functionalities. We have too many paths that come into here and too many remaining cards on the old Cost/Target system. Once every hardcoded card uses the new Cost/Target system then I can actually get started getting the issue fixed.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 9 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 9 users online :: 0 registered, 0 hidden and 9 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 9 guests

Login Form