netrunner icon indicating copy to clipboard operation
netrunner copied to clipboard

Auto-pumping icebreakers implementation

Open nealterrell opened this issue 11 years ago • 7 comments

I am working on the auto-pumping functionality for icebreakers suggested in #259 . This is what I have so far:

curtain1 curtain2

There is some technical trickery to get this to work that I won't get into here... it involves self-modifying a card's Abilities vector to insert or remove the "match strength" pseudo-ability when appropriate. I was able to implement this using the event-handling system we already have, so there are very few changes to the core... but now I'm trying to find the best way to incorporate the system into all the icebreaker code.

I have created an event handler breaker-auto-pump (here) that needs to be hooked up to 5 events for the system to work. That would mean adding event handlers manually to every icebreaker so they all look something like this:

"Corroder"
{:abilities [{:cost [:credit 1] :msg "break 1 barrier subroutine"}
             {:cost [:credit 1] :msg "add 1 strength" :effect (effect (pump card 1)) :pump 1}]
  :data {:breaks ["Barrier"]}
  :events {:encounter-ice breaker-auto-pump :pass-ice breaker-auto-pump
           :run-ends breaker-auto-pump :ice-strength-changed breaker-auto-pump
           :breaker-strength-changed breaker-auto-pump}}

Not the end of the world, but tedious, and if the system should need expanding to include new events.... ugh. So I then wrote a helper function auto-icebreaker to merge the necessary events into a card definition (here). This turns Corroder into

"Corroder"
 (auto-icebreaker ["Barrier"]
   {:abilities [{:cost [:credit 1] :msg "break 1 barrier subroutine"}
                {:cost [:credit 1] :msg "add 1 strength" :effect (effect (pump card 1)) :pump 1}]})

I think this works well. It will mean updating all icebreakers with the auto-icebreaker line and the closing ), and marking all "pump" abilities with :pump _X_, but after that small bit of tedious work the whole system should adapt well to future changes.

@mtgred, what do you think of this? Particularly incorporating the events into each icebreaker. Is there something more Clojurely I should look into? (If this was OOP, for example, I would probably introduce a new base class AutoIcebreaker and then derive icebreaker programs from that class.)

@JoelCFC25, would you be up for helping me incorporate this into the ~50 icebreakers?

nealterrell avatar Jul 06 '15 17:07 nealterrell

I'll for sure do some copy/paste grunt work assuming this plan gets a :+1: from the boss.

JoelCFC25 avatar Jul 06 '15 17:07 JoelCFC25

The helper approach looks good. You can go ahead.

mtgred avatar Jul 06 '15 18:07 mtgred

Alrighty @JoelCFC25, let's give this a shot. I've synced my changes to https://github.com/nealterrell/netrunner/ branch "auto-pump". If you have some free time, check out the change to Gordian Blade and Corroder, then try modifying a few icebreakers and submit a change to my repo. In general, you will be taking the body of an icebreaker's definition and wrapping it in an (auto-icebreaker) function call. You will also be annotating "pump" abilities with a key :pump X, where X is the amount the ability pumps by. We will only do this for pumpable breakers.

nealterrell avatar Jul 08 '15 02:07 nealterrell

What will the first line of Crypsis and Eater look like? Will it have to include the oddball subtypes to be able to autopump on them?

(auto-icebreaker ["Barrier" "Code Gate" "Sentry" "Trap" "Mythic"]

JoelCFC25 avatar Jul 08 '15 02:07 JoelCFC25

Let's go with just "All". I will amend the code to reflect that option. On Jul 7, 2015 7:59 PM, "Joel Koepp" [email protected] wrote:

What will the first line of Crypsis and Eater look like? Will it have to include the oddball subtypes to be able to autopump on them?

(auto-icebreaker ["Barrier" "Code Gate" "Sentry" "Trap" "Mythic]

— Reply to this email directly or view it on GitHub https://github.com/mtgred/netrunner/issues/336#issuecomment-119406439.

nealterrell avatar Jul 08 '15 03:07 nealterrell

Sorry to ask a follow-up: will (auto-icebreaker ["Tracer"] work for Gingerbread and (auto-icebreaker ["Destroyer"]work for Sharpshooter, or should I leave these alone for now?

JoelCFC25 avatar Jul 08 '15 13:07 JoelCFC25

Those should indeed work as you expect. On Jul 8, 2015 6:51 AM, "Joel Koepp" [email protected] wrote:

Sorry to ask a follow-up: will (auto-icebreaker ["Tracer"] work for Gingerbread and (auto-icebreaker ["Destroyer"]work for Sharpshooter, or should I leave these alone for now?

— Reply to this email directly or view it on GitHub https://github.com/mtgred/netrunner/issues/336#issuecomment-119585730.

nealterrell avatar Jul 08 '15 13:07 nealterrell