netrunner icon indicating copy to clipboard operation
netrunner copied to clipboard

Simultaneous triggers with multiple required selections are problematic

Open anathomical opened this issue 11 years ago • 10 comments

This is basically the same problem at the root of #322, but probably generalizable.

If two card effects are triggered simultaneously, and they both require multiple player choices in order to resolve, the decision trees are cycled through with one step for each tree resolved before any successive steps are shown. An easy way to reproduce this is to have three rezzed copies of Team Sponsorship installed, and then scoring an agenda. The result will be the following series of prompts:

  1. Install from HQ or Archives.(first Team Sponsorship)
  2. Install from HQ or Archives.(second Team Sponsorship).
  3. Install from HQ or Archives..(third Team Sponsorship)
  4. Select card to install.(first Team Sponsorship)
  5. Select card to install.(second Team Sponsorship)
  6. Select card to install.(third Team Sponsorship)
  7. Choose where to install your card. (first Team Sponsorship)
  8. Choose where to install your card. (second Team Sponsorship)
  9. Choose where to install your card. (third Team Sponsorship)

Without looking at the code, I can't say for sure, but I'm betting that this is because there's a single FIFO stack of decision prompts, the first three triggers in this example are all put on the stack, giving you the first three prompts. Further, answering a prompt puts a new prompt on back end of the stack instead of the front end of the stack.

If possible, the cleanest solution is probably to figure out a way to get prompts that are created from currently-active prompts to go to the front of the stack rather than the back of the stack, so that they at least all get resolved before the next one triggers.

Note that this isn't a full solution as it will sometimes matter which order the two prompts go on the stack in, and there's currently no way to control for that, but just making sure that effects fully resolve before additional effects are handled would probably fix a large number of tricky interactions.

anathomical avatar Sep 25 '15 03:09 anathomical

Note: also related to #748 and #690

anathomical avatar Sep 25 '15 03:09 anathomical

That is indeed the reason, though we do have the ability to push to the front of the queue, just not at specific positions. More generally, we don't have a way for execution of the engine to pause until a prompt is resolved, which would solve all these issues. Sometimes we can work around the issue -- I submitted a fix for Team Sponsorship in #756. But we are aware of the fundamental issues and are slowly attempting to piece together a fix.

nealterrell avatar Sep 25 '15 18:09 nealterrell

Again, not having dug into the code, I can't say for sure, but if triggers are chained, it might be as simple as pushing to front-of-queue, right? If :effects that generate :prompts always push those :prompts to the front of the queue, rather than the back, you should end up with defacto serial resolution. Maybe. Basically, because multi-prompt effects are actually a series of prompts, each generated during the resolution of the last, converting the prompt queue to be FILO rather than FIFO may resolve some of these problems. (Though, clearly, not all of them.)

Such that: prompts_queue = []

  1. Team Sponsorship 1 triggers prompts_queue = [TS1 Hq/Archives]
  2. Team Sponsorship 2 triggers prompts_queue = [TS2 Hq/Archives, TS1 Hq/Archives]
  3. Team Sponsorship 3 triggers prompts_queue = [TS3 Hq/Archives, TS2 Hq/Archives, TS1 Hq/Archives]
  4. User prompted to select HQ or Archives for TS3 prompts_queue = [TS3 Pick Card, TS2 Hq/Archives, TS1 Hq/Archives]
  5. User selects card for TS3 prompts_queue = [TS3 Where to install, TS2 Hq/Archives, TS1 Hq/Archives]
  6. User prompted to select HQ or Archives for TS2 prompts_queue = [TS2 Pick Card, TS1 Hq/Archives] ... And so on.

Cases where this clearly won't work are when an effect is triggered, but intended to resolve at the END of the queue, such as with Comet, which wants you to resolve the event you played before triggering. Though there's probably nothing preventing prompts to be placed at the beginning or end of the queue on a case-by-case basis? Again, not solving all situations, such as those where players may want to determine a specific beneficial resolution order.

anathomical avatar Sep 25 '15 19:09 anathomical

Good observation. That might do the trick for many of the problematic cards. I'll look into it. :+1:

nealterrell avatar Sep 25 '15 19:09 nealterrell

So cards that show multiple prompts could simply use :priority true: in all prompts but the first? Maybe that will work.

queueseven avatar Sep 25 '15 19:09 queueseven

I have been messing around with :priority true, but I clearly don't fully understand it. It seems like it should be going to the front of [:runner :prompt] since show-prompt is doing a cons onto the existing vector. In testing I still get prompts from 2 different cards interspersed with each other.

JoelCFC25 avatar Oct 27 '15 14:10 JoelCFC25

Are there any remaining notable cases for this issue?

JoelCFC25 avatar May 13 '16 17:05 JoelCFC25

Do a test game as Combo-CI. AD + Interns + SfSS had similar weird prompt orderings when I tried it a few weeks ago.

Saintis avatar May 13 '16 17:05 Saintis

That case should have been solved in #1494, I'm pretty sure. I don't know how to do Combo-CI actually _brain melts_.

JoelCFC25 avatar May 13 '16 17:05 JoelCFC25

We have a good solution to his now, but it has only been applied to agenda-stolen and agenda-scored events. We will slowly deploy it as needed to other event triggers, but I think this can be closed now.

nealterrell avatar Jun 09 '16 00:06 nealterrell