:trash event is fired before prevent effects
Say I have Cache, Q-Coherence Chip and Sacrificial Construct in play and I facecheck an ICE that trashed a program, so the corp trashes Cache.
Expected behaviour: I can use Sacrificial Construct to prevent the trashing of Cache; and only Sacrificial Construct will be trashed
Actual behaviour: I'm asked if I want to use Sacrificial Construct to prevent the trashing of Q-Coherence Chip. If I don't do this, I'm asked if I want to prevent the trashing of Cache. I do so, but now Sacrificial Construct and Q-Coherence Chip are trashed.
The problem is that the :trash event is triggered before preventing the trashing is handled.
Yes, many events fire before their action is fully resolved. I don't know why this is. I guess we can think of :trash as really being "pre-trash".
You could try moving the event trigger to resolve-trash, but you'll need to check to see if anything else breaks. You could also just add a new event like :trashed or :post-trash and then handle that in Q-Coherence.
I think moving the event trigger is the way to go. There are not many :trash event listener, and none of those should fire when the trash effect is prevented.
I moved the trigger out of trash and into resolve-trash as mentioned above, so the originally described scenario of Cache, Q-Coherence Chip and Sacrificial Construct now works correctly when Cache is targeted for trashing. Are there any other cards to check to see if this will break anything?
@JoelCFC25 did you commit/PR your changes you talked about?
No, never did. Just tested the one limited scenario but didn't get into it exhaustively to see if it broke other stuff.
Will this be easy to fix now with when-completed?
I just checked this and indeed the when-completed framework results in the correct outcome!