It is currently 12 Sep 2025, 05:41
   
Text Size

New trigger: Always

Post MTG Forge Related Programming Questions Here

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

New trigger: Always

Postby Sloth » 08 Jul 2011, 19:36

I've added a new trigger: Always. It triggers whenever static effects are checked. Example cards are Synod Centurion, Barbarian Outcast, Dandan etc.

The problem is that these triggers have conditions when they will trigger, but these are no intervening if clauses. The conditions should not be checked a second time on resolution. What's the best way to handle this? Are there any other triggers that have a similar problem?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New trigger: Always

Postby friarsol » 08 Jul 2011, 20:24

Firstly, Did this file make it onto the server? I seem to be getting errors in my Eclipse.

I think the only way to handle this is in TriggerHandler.java wrapperAbility.resolve() line 855ish

Code: Select all
if (!regtrig.requirementsCheck()) {
   return;
}
Before that requirementsCheck happens we would need to check if the Trigger is (or is not) an Intervening If. I think it's more common to have an Intervening If, so we should probably leave that as the default. So these cards would have some type of "SkipResolveCheck$ True" as a parameter, which would be set before the Ability was created.

Code: Select all
final boolean skipResolveCheck = trigParams.containsKey("SkipResolveCheck");
// ...
if (!skipResolveCheck && !regtrig.requirementsCheck()) {
   return;
}
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New trigger: Always

Postby friarsol » 08 Jul 2011, 20:31

Also, here's some info about "State Triggers":

"When you control no permanents with phylactery counters on them, sacrifice Phylactery Lich."

"Phylactery Lich's last ability is a "state trigger." Once a state trigger triggers, it won't trigger again as long as the ability is on the stack. If the ability is countered and the trigger condition is still true, it will immediately trigger again."

We should make sure that gets implemented while you're in this part of the code.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New trigger: Always

Postby Hellfish » 08 Jul 2011, 20:36

Original:
Not currently. My thinking is adding another parameter to specify InterveningIf$ True or False rather than
basically duplicate Trigger.requirementsCheck().

Post-Sol: (:P)
Yeah, basically SkipRequirementsCheck$. As for the state trigger business, if the ability is countered: the countering ability would resolve, state effects would be checked again and the trigger would go off again. Or have I misunderstood when our state effects are checked?
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: New trigger: Always

Postby Sloth » 08 Jul 2011, 20:44

friarsol wrote:Firstly, Did this file make it onto the server? I seem to be getting errors in my Eclipse.
Fixed. I always forget the new files.

Hellfish wrote:Post-Sol: (:P)
Yeah, basically SkipRequirementsCheck$. As for the state trigger business, if the ability is countered: the countering ability would resolve, state effects would be checked again and the trigger would go off again. Or have I misunderstood when our state effects are checked?
The trigger would trigger again after the next ability hits the stack. Maybe an infinite loop is possible here. :?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New trigger: Always

Postby friarsol » 08 Jul 2011, 20:45

Hellfish wrote:As for the state trigger business, if the ability is countered: the countering ability would resolve, state effects would be checked again and the trigger would go off again. Or have I misunderstood when our state effects are checked?
The important part is: while it might get checked at each State Check, it only goes on the Stack if it's not already on the Stack. This is only important in a complex example.

Example:
I have an Emperor Crocodile with no other creatures. It's trigger goes on the stack. In response I cast Carrion Call. The trigger doesn't go on the stack again because it's already on. The Call resolves. Then Croc's trigger resolves and it gets sacrificed.

Example2:
I have an Emperor Crocodile with no other creatures. It's trigger goes on the stack. In response I cast Stifle on the trigger. In response to that I cast Carrion Call. Call resolves. I get some tokens. Stifle resolves countering Croc's trigger. Now we have a State Check, but I now have creatures, so the State Trigger doesn't occur.

Edit: Fixing some poor wording
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New trigger: Always

Postby Hellfish » 08 Jul 2011, 21:28

Ah, that's gonna require some additional tracking...
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: New trigger: Always

Postby friarsol » 08 Jul 2011, 21:41

Sloth wrote:The trigger would trigger again after the next ability hits the stack. Maybe an infinite loop is possible here. :?
Infinite Loops is the other reason it doesn't go on the stack if it's already on. :-d
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New trigger: Always

Postby Hellfish » 09 Jul 2011, 10:47

It wasn't as bad as I feared, actually, just an extra field in SpellAbility,an extra method in MagicStack and a couple of if's in runSingleTrigger. Of course, I still have to verify it all :mrgreen:
EDIT:Looks good to me, the examples and some additional tests check out fine!
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: New trigger: Always

Postby Sloth » 09 Jul 2011, 16:09

Hellfish wrote:It wasn't as bad as I feared, actually, just an extra field in SpellAbility,an extra method in MagicStack and a couple of if's in runSingleTrigger. Of course, I still have to verify it all :mrgreen:
EDIT:Looks good to me, the examples and some additional tests check out fine!
Thanks for fixing this Hellfish.
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 36 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 36 users online :: 0 registered, 0 hidden and 36 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 36 guests

Login Form