Trigger code question (re: suppression)
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
24 posts
• Page 1 of 2 • 1, 2
Trigger code question (re: suppression)
by 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:
Is there an obvious mistake here, or does anyone know what's going on?
Thanks,
slapshot5
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);
}
}
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)
by 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);
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
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
-
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)
by slapshot5 » 08 Sep 2011, 05:52
I'll give it a try and report back.Hellfish wrote:Adding a lineto the getCopy method of every trigger type might work.
- Code: Select all
copy.setSuppressed(suppressed);
-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)
by slapshot5 » 08 Sep 2011, 05:57
Unfortunately, it wasn't that easy. The trigger still fired.slapshot5 wrote:I'll give it a try and report back.
-slapshot5
-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)
by 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).
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).
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Trigger code question (re: suppression)
by slapshot5 » 08 Sep 2011, 06:07
Not anymore. I expected it to be suppressed until I called c.setSuppression(false);.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).
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)
by Sloth » 08 Sep 2011, 10:11
We can add a second boolean temporarySuppressed which resets and suppressed will not.slapshot5 wrote:Not anymore. I expected it to be suppressed until I called c.setSuppression(false);.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).
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?
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.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Trigger code question (re: suppression)
by 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
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
-
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)
by Sloth » 08 Sep 2011, 10:32
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).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.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Trigger code question (re: suppression)
by 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
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
-
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)
by Sloth » 08 Sep 2011, 10:45
Yes, I've just added it. Snapshot can do a test again without changing anything.Hellfish wrote:Ah,gotcha. Then we may need separate suppression for static effect/other..
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Trigger code question (re: suppression)
by 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
- 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)
by Sloth » 08 Sep 2011, 15:00
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.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
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Trigger code question (re: suppression)
by slapshot5 » 09 Sep 2011, 01:23
I checked in as 10313. I was testing with Mystic Compass: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.
- | 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},: 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)
by 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
Edit: r10311
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
24 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 64 guests