Page 1 of 2

Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 05:23
by slapshot5
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

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 05:44
by Hellfish
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.

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 05:52
by slapshot5
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

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 05:57
by slapshot5
slapshot5 wrote:I'll give it a try and report back.

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

-slapshot5

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 06:03
by Sloth
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).

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 06:07
by slapshot5
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?

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 10:11
by Sloth
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.

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 10:29
by Hellfish
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.

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 10:32
by Sloth
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).

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 10:36
by Hellfish
Ah,gotcha. Then we may need separate suppression for static effect/other..

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 10:45
by Sloth
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.

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 13:38
by slapshot5
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

Re: Trigger code question (re: suppression)

PostPosted: 08 Sep 2011, 15:00
by Sloth
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.

Re: Trigger code question (re: suppression)

PostPosted: 09 Sep 2011, 01:23
by slapshot5
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

Re: Trigger code question (re: suppression)

PostPosted: 09 Sep 2011, 03:54
by friarsol
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