Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Recurring and Placed Credits #4262

Merged
merged 44 commits into from
Jun 10, 2019

Conversation

lostgeek
Copy link
Contributor

@lostgeek lostgeek commented May 30, 2019

Overview

Currently, paying costs is awaitable through pay-sync, but we delegate individual cost types to their own functions which may or may not individually be awaited, and right now paying credits is not. This PR introduces a new function that will check for any installed and active cards that have usable credits, and if so, will open a select prompt that's based on the pick-virus-counters-to-spend function (used for Khumalo and the Khumalo breakers) to pay or partially pay the appropriate cost.

Changelog

Costs

  • Create new awaited cost handler for credits: pay-credits
  • Wrote a bunch of helper functions to be used in that service
  • Expand can-pay? to accept an eid to check installed cards for the appropriate credits
  • Add :pay-credits to :interactions map, which connects the credits on the card (or a custom function) with the pay-credits function. It currently has 3 usable fields:
    • :req: Works as other reqs, checking to see whether the current action is the right kind to use this card's credits/ability
    • :type: Only 3 allowed values: :credit, :recurring, and :custom. :credit is for credits that are placed on the card (eg Miss Bones or Cold Read). :recurring is for recurring credits (eg Smoke or Dedicated Server). :custom is for cards that have payment-related abilities but aren't placed/recurring credits (eg Flame-out or Patchwork)
    • :custom: Only used when :type is :custom. Effectively an :effect map, it's an async 5-fn that should use make-result to return the amount of credits that will be applied to the effect.

Engine

  • Update make-eid calls to use existing eid for passing along :source and :source-type where appropriate
  • Update make-eid calls at base levels (actions) to provide the necessary :source-type
  • Make advancing cards payment awaited
  • Make removing tag payment awaited
  • Make runner install payment awaited
  • Add :play-area to all-active for each side

Runs

  • Make paying for runs awaited
  • Clean up can-pay logic so we know definitively if the runner can pay to trash a given card or not
  • Make paying to trash an accessed card awaited, which cleans up the issue of repeatedly showing the prompt if you haven't taken enough credits from cards
  • Fix bug where handle-run-end would dissoc :access even tho it was still happening

Traces

  • Refactor/clean up to be properly awaited
  • Pull out traces as their own process in prompt-handling logic, so as to display the true number of available credits
  • Pull out traces in the UI logic as well to handle the above
  • Remove paying for traces in prompt-handling, use pay-sync within trace prompts where appropriate

Cards

See below for full list of implemented cards

Tests

See below for full list of implemented cards. Every single one got a small test for this functionality

@lostgeek lostgeek changed the title First approach to implementing a credits prompt Implementing prompts for usage of (recurring) credits May 30, 2019
src/clj/game/cards.clj Outdated Show resolved Hide resolved
src/clj/game/cards.clj Outdated Show resolved Hide resolved
src/clj/game/cards.clj Outdated Show resolved Hide resolved
@lostgeek
Copy link
Contributor Author

lostgeek commented Jun 1, 2019

Cards that benefit from this implementation

  • Installing cards (runner)
    • Cyberfeeder (virus)
    • Cybsoft MacroDrive
    • Ice Analyzer
    • Inside Man
    • Sahasrara
    • Patchwork
  • Stealth
    • Cloak
    • Cold Read
    • Dyson Fractal Generator
    • Smoke
    • Ghost Runner
    • Lockpick
    • Net Mercur
    • Silencer
    • Trickster Taka
  • Paid abilities on icebreakers/programs
    • Cyberfeeder
    • Flame-out
    • Multithreader
    • Omni-drive
    • Spinal Modem
    • The Toolbox
  • Credits during the run
    • Maui
    • Net Celebrity
    • Pheromones
  • Trashing cards
    • Miss Bones
    • Paricia
    • Scrubber
    • Whizzard
  • Play events
    • Prepaid VoicePAD
    • Public Terminal
    • Patchwork
  • Removing Tags
    • Crash Space
  • Rez cards
    • Dedicated Server
    • Khondi Plaza
    • Mumba Temple
    • The Root
  • Installing cards (Corp)
    • Dedicated Technician Team
    • The Root
  • Advance cards
    • Simone Diego
    • Weyland Because We Built It
    • The Root
  • Traces
    • Compromised Employee
    • NBN:MN
    • Net Police
    • Primary Transmission Dish

@NoahTheDuke
Copy link
Collaborator

I think Net Mercur needs a better req, but I’m loving this.

@lostgeek
Copy link
Contributor Author

lostgeek commented Jun 1, 2019

ToDo List

  • Make play-auto-pump awaitable and group together costs
  • Build a break-ice-full mechanism to group together all breaking related costs
  • Include credit providing cards in can-pay?
  • Write tests for installing cards (Runner)
  • Write tests for Stealth
  • Write tests for paid abilities on icebreakers/programs
  • Write tests for credits during the run
  • Write tests for trashing cards
  • Write tests for playing events
  • Write tests for removing tags
  • Write tests for rezzing cards
  • Write tests for installing cards (Corp)
  • Write tests for advancing cards
  • Write tests for traces
  • Check why Flame-out doesn't produce a message when using the breaker on it

@NoahTheDuke
Copy link
Collaborator

With removing tags, make sure you effect-complete payment and non-payment.

(lose-tags state :runner 1)
(system-msg state side (build-spend-msg cost-str "remove 1 tag" "removes 1 tag"))
(play-sfx state side "click-remove-tag"))))
(wait-for (pay-sync state side (make-eid state {:source :action :source-type :remove-tag}) nil :click 1 :credit remove-cost)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since removing tags is now awaitable, I should test a case of Sahasrara + Thunder Art Gallery to check if all the prompts are handled correctly.

src/clj/game/cards.clj Outdated Show resolved Hide resolved
@NoahTheDuke NoahTheDuke mentioned this pull request Jun 7, 2019
14 tasks
@lostgeek
Copy link
Contributor Author

lostgeek commented Jun 9, 2019

I think we're done here! 🎊

@NoahTheDuke
Copy link
Collaborator

Thinking about Net Mercur more, I think we could get 80% by requiring :icebreaker, :run, or :trace. By my count, that will cover nearly all uses. If someone wants to use it to play or install, they can manually take credits off. Everything else I can think of falls under those uses.

What do you think?

@NoahTheDuke NoahTheDuke changed the title Implementing prompts for usage of (recurring) credits Implement Recurring and Placed Credits Jun 9, 2019
@NoahTheDuke NoahTheDuke merged commit 9125ac8 into mtgred:master Jun 10, 2019
@NoahTheDuke
Copy link
Collaborator

Closes #362

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants