netrunner icon indicating copy to clipboard operation
netrunner copied to clipboard

Question: implementing Hivemind

Open nealterrell opened this issue 11 years ago • 5 comments

I am working on implementing Hivemind. It is tricky, needless to say.

Currently I have a new function in Core called get-virus-counters. It returns the sum of a card's virus counters with the number of counters on an installed Hivemind. Cards that use counters passively --Gorman Drip, Medium, Nerve Agent, and Deep Thought -- simply need to call get-virus-counters in their ability triggers instead of just using their own :counters value. These cards work fine.

The harder use case is for abilities that consume counters: Cache, Imp, Datasucker, Gravedigger, Hemorrhage, Crypsis. These cards should be able to trigger their abilities if (card's counters + Hivemind's counters) >= ability cost, and should be able to spend a Hivemind counter for the ability if necessary.

I have four thoughts on how to approach this:

  1. Give Hivemind a single ability to transfer a counter to another virus. Then the user can activate that virus to spend the counter.

    Example: click Hivemind; select Cache to move 1 counter. Click Cache to consume the counter and gain 1 credit.

    PROS: simplest to implement (I have it done already). CONS: does not automate using the target virus, so the user could skip that step (cheating). Probably un-intuitive at first, as you would otherwise start by clicking the card you want to activate (Cache/Imp).

  2. Give Hivemind an ability to trigger another virus card's active ability. On clicking Hivemind, prompt to select an installed :subtype "Virus" that has an ability with a :counter-cost that is less than the sum of Hivemind's counters and the target's counters. Add the requisite counters to the target, remove counters from Hivemind, and resolve the ability's :effect.

    Example: click Hivemind; select Cache to lose 1 counter from Hivemind, gain 1 credit. Example: during a run when accessing, click Hivemind; select Imp to lose 1 counter from Hivemind, trash accessed card.

    PROS: Makes it clear that the Hivemind token is being spent. Doesn't require changing any existing cards. CONS: Probably the most complicated to implement.

  3. Give every virus with an ability a second ability to spend a Hivemind counter to trigger the card's effect.

    Example: click Cache; two abilities show, one to gain 1 credit, another to spend a Hivemind counter to gain 1 credit.

    PROS: makes it clear what is happening. Consistent starting point (always with the card that is acting). CONS: doubles the # of clicks for activating the base ability of these cards, as now the game will show a menu that requires a second click.

  4. Rework all virus ability triggers to consume a counter from Hivemind if there are insufficient counters on the card.

    Example: click Cache; if no counters are on Cache, consume a counter from Hivemind, then trigger the ability as normal.

    PROS: fewest changes to user interface. Single click to trigger actions, as currently. CONS: no warning, so prone to accidents. If the user clicks Cache one too many times (server lag, click-happy, etc.), Cache will automatically consume a very valuable Hivemind token with no way of recovering it. Requires changing code for all the existing virus abilities.

I suppose a final option would be to take option 4 and add a confirmation prompt if the card wants to use a Hivemind token.

Any thoughts from users or developers? What is going to give the best user experience?

nealterrell avatar May 12 '15 17:05 nealterrell

I vacillate between preferring options 2 and 3. I'm guessing this would be fiendishly difficult to do, but would there be a way to--forgive me, I'm not a programmer so I'm going to mangle the terminology--create the equivalent of a global variable to track whether or not a Hivemind is active?

Then the viruses that consume tokens could keep their existing behavior (click it to consume the token as per usual) when no Hivemind is out. When a Hivemind is active, only then would the "click to show the menu" functionality become active.

JoelCFC25 avatar May 13 '15 16:05 JoelCFC25

The global variable equivalent is actually easy, so yes, we can add a method for checking to see if a Hivemind is active. Unfortunately I can't currently figure out how to flag a card ability as "only SHOW this ability if this condition is true." Abilities can be flagged to only TRIGGER if a condition is true, but I haven't seen a way to toggle their visibility based on a condition. Any card with more than one ability will show a menu on click, even if one of the abilities can't actually be used. @mtgred would have to guide me on changing the UI code if we wanted to go that route.

I can think of a workaround outside of the UI, whereby viruses "listen" for Hivemind installs/uninstalls and modify their ability sets in the middle of the game, but that would be a lot of work :(.

nealterrell avatar May 13 '15 16:05 nealterrell

Updates.

I basically fully implemented option 2 (click Hivemind, click Virus to transfer a counter and immediately trigger the virus ability). It worked just fine with Cache, but I came across a difficulty when testing with Imp. The engine really doesn't like me opening a prompt while the "You have accessed ..." message is showing, which is the normal time to use Imp to trash at no cost. Normally, clicking Hivemind gives a prompt to select a target, but in this access scenario, no prompt is shown, and when I then click Imp to finish the Hivemind trigger, the engine reports an exception.

I suspect the engine doesn't support showing a new prompt while another is being resolved. I don't know how to resolve that, so I will go back to the drawing board and try option 4 with the warning prompt, which was my favorite option in terms of ease of use.

nealterrell avatar May 16 '15 02:05 nealterrell

New prompts are added at the end of a prompt queue. Adding the new prompt at the beginning of the queue would make it work for Imp. You can maybe add a parameter to the prompt function to add it at the front instead of the end.

I like the option 2 better as it is explicit. But option 4 is fine too.

mtgred avatar May 16 '15 10:05 mtgred

Thanks @mtgred. That was the hint I needed :).

nealterrell avatar May 17 '15 00:05 nealterrell