It is currently 13 Sep 2025, 22:53
   
Text Size

Trigger code question (re: suppression)

Post MTG Forge Related Programming Questions Here

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

Trigger code question (re: suppression)

Postby slapshot5 » 08 Sep 2011, 05:23

Hello,

I'm running into some unexpected problems when trying to suppress a particular trigger.

I'm in the AF_Animate code. A card is supposed to lose triggers until end of turn. Pretty standard.

I'm trying to do this:
Code: Select all
//suppress triggers from the animated card
            final ArrayList<Trigger> removedTriggers = new ArrayList<Trigger>();
            if (params.containsKey("OverwriteTriggers")) {
                ArrayList<Trigger> triggersToRemove = c.getTriggers();
                for (Trigger trigger : triggersToRemove) {
                    trigger.setSuppressed(true);
                }
            }
This doesn't work however for my test using City of Brass. I know this code has run for City of Brass, then tap City of Brass, and the trigger fires. The debugger is telling me that the trigger that fired (say, id=156) is different than the trigger I suppressed (say, id=252). There is only 1 City of Brass in the game.

Is there an obvious mistake here, or does anyone know what's going on?

Thanks,
slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Trigger code question (re: suppression)

Postby Hellfish » 08 Sep 2011, 05:44

I don't have as much time as I want for this atm (The Graft bug is suffering too >_>) but my best guess right now is that the problem is that in the Trigger_X classes, the member variable suppressed isn't copied in the getCopy method. Adding a line
Code: Select all
copy.setSuppressed(suppressed);
to the getCopy method of every trigger type might work.
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: Trigger code question (re: suppression)

Postby slapshot5 » 08 Sep 2011, 05:52

Hellfish wrote:Adding a line
Code: Select all
copy.setSuppressed(suppressed);
to the getCopy method of every trigger type might work.
I'll give it a try and report back.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Trigger code question (re: suppression)

Postby slapshot5 » 08 Sep 2011, 05:57

slapshot5 wrote:I'll give it a try and report back.

-slapshot5
Unfortunately, it wasn't that easy. The trigger still fired.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Trigger code question (re: suppression)

Postby Sloth » 08 Sep 2011, 06:03

I don't know exactly what causes the bug you mention, but I suspect LastKnownInformation could be responsible.

That aside, are you sure you want to use suppressed for AF Animate? The suppression gets cleared all the time (whenever static effects are checked).
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Trigger code question (re: suppression)

Postby slapshot5 » 08 Sep 2011, 06:07

Sloth wrote:That aside, are you sure you want to use suppressed for AF Animate? The suppression gets cleared all the time (whenever static effects are checked).
Not anymore. I expected it to be suppressed until I called c.setSuppression(false);.

I suppose that means remove the trigger from the card, unregister from TriggerHandler, then at EOT, re-add the trigger and re-register with TriggerHandler?
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Trigger code question (re: suppression)

Postby Sloth » 08 Sep 2011, 10:11

slapshot5 wrote:
Sloth wrote:That aside, are you sure you want to use suppressed for AF Animate? The suppression gets cleared all the time (whenever static effects are checked).
Not anymore. I expected it to be suppressed until I called c.setSuppression(false);.

I suppose that means remove the trigger from the card, unregister from TriggerHandler, then at EOT, re-add the trigger and re-register with TriggerHandler?
We can add a second boolean temporarySuppressed which resets and suppressed will not.

EDIT: Now suppressed won't be reset all the time.
Last edited by Sloth on 08 Sep 2011, 10:29, edited 1 time in total.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Trigger code question (re: suppression)

Postby Hellfish » 08 Sep 2011, 10:29

Why does the static ability code use setSuppressed? If it's what I think it is (keeping ANY triggers whatsoever from going off while static effects are applied) then it would be better to add a way for static abilities to do TriggerHandler.suppressMode("All") and use Trigger.set/isSuppressed for OP's exact purpose.
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: Trigger code question (re: suppression)

Postby Sloth » 08 Sep 2011, 10:32

Hellfish wrote:Why does the static ability code use setSuppressed? If it's what I think it is (keeping ANY triggers whatsoever from going off while static effects are applied) then it would be better to add a way for static abilities to do TriggerHandler.suppressMode("All") and use Trigger.set/isSuppressed for OP's exact purpose.
It's something I've added last week for cards like Lignify. Triggered abilities on the card enchanted by Lignify will be suppressed (since they aren't there any more).
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Trigger code question (re: suppression)

Postby Hellfish » 08 Sep 2011, 10:36

Ah,gotcha. Then we may need separate suppression for static effect/other..
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: Trigger code question (re: suppression)

Postby Sloth » 08 Sep 2011, 10:45

Hellfish wrote:Ah,gotcha. Then we may need separate suppression for static effect/other..
Yes, I've just added it. Snapshot can do a test again without changing anything.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Trigger code question (re: suppression)

Postby slapshot5 » 08 Sep 2011, 13:38

Initial test indicates this still doesn't work. (I had to uncomment setSuppressed(boolean supp) in Trigger.java - Did you mean to comment that out?) I do have suppressed getting copied in getCopy for Trigger_Taps.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Trigger code question (re: suppression)

Postby Sloth » 08 Sep 2011, 15:00

slapshot5 wrote:Initial test indicates this still doesn't work. (I had to uncomment setSuppressed(boolean supp) in Trigger.java - Did you mean to comment that out?) I do have suppressed getting copied in getCopy for Trigger_Taps.

-slapshot5
Blood Moon still suppresses City of Brass. I don't see a reason that it should not work. If you want you can just commit your code and I'll help track down what's happening.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Trigger code question (re: suppression)

Postby slapshot5 » 09 Sep 2011, 01:23

Sloth wrote:Blood Moon still suppresses City of Brass. I don't see a reason that it should not work. If you want you can just commit your code and I'll help track down what's happening.
I checked in as 10313. I was testing with Mystic Compass:

| Open
Name:Mystic Compass
ManaCost:2
Types:Artifact
Text:no text
A:AB$ ChooseType | Cost$ 1 T | Defined$ You | Type$ Basic Land | SubAbility$ SVar=DBAnimate | SpellDescription$ Target land becomes the basic land type of your choice until end of turn.
SVar:DBAnimate:DB$ Animate | ValidTgts$ Land | TgtPrompt$ Select target land | Types$ ChosenType | OverwriteTypes$ True | KeepSupertypes$ True | KeepCardTypes$ True | OverwriteAbilities$ True | OverwriteTriggers$ True
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/mystic_compass.jpg
Oracle:{1}, {T}: Target land becomes the basic land type of your choice until end of turn.
End


Also, I just tested with Blood Moon and City of Brass. With both in play, I tapped City of Brass and the trigger *did* fire.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Trigger code question (re: suppression)

Postby friarsol » 09 Sep 2011, 03:54

I have a Lignify on a Wort, Boggart Auntie but it seems to be still triggering even though it's card text has been removed. I'm sure this is related to this discussion so I didn't file a bug about.
Edit: r10311
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 35 guests

Main Menu

User Menu

Our Partners


Who is online

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

Login Form