Skip to content

Commit

Permalink
first impl with revealed hand
Browse files Browse the repository at this point in the history
  • Loading branch information
NBKelly committed Oct 30, 2024
1 parent d9dfc0b commit 62a4126
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
44 changes: 16 additions & 28 deletions src/clj/game/cards/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[game.core.cost-fns :refer [install-cost play-cost rez-cost]]
[game.core.damage :refer [damage damage-prevent]]
[game.core.def-helpers :refer [breach-access-bonus choose-one-helper defcard offer-jack-out
reorder-choice]]
reorder-choice with-revealed-hand]]
[game.core.drawing :refer [draw]]
[game.core.effects :refer [register-lingering-effect]]
[game.core.eid :refer [complete-with-result effect-completed make-eid
Expand Down Expand Up @@ -4172,33 +4172,21 @@
(register-events card (rfg-card-event target)))}]}))

(defcard "White Hat"
(letfn [(finish-choice [choices]
(let [choices (filter #(not= "Done" %) choices)]
(when (not-empty choices)
{:effect (req (doseq [c choices]
(move state :corp c :deck))
(shuffle! state :corp :deck))
:msg (str "shuffle " (enumerate-str (map :title choices)) " into R&D")})))
(choose-cards [choices chosen]
{:prompt (str "Choose a card in HQ to shuffle into R&D (" (- 2 (count chosen)) " remaining)")
:player :runner
:choices (concat choices ["Done"])
:not-distinct true
:async true
:effect (req (if (and (empty? chosen)
(not= "Done" target))
(continue-ability state side (choose-cards (remove-once #(= % target) choices) (conj chosen target)) card nil)
(continue-ability state side (finish-choice (conj chosen target)) card nil)))})]
{:on-play
{:trace
{:base 3
:req (req (some #{:hq :rd :archives} (:successful-run runner-reg)))
:unsuccessful
{:async true
:msg (msg "reveal " (enumerate-str (map :title (:hand corp))) " from HQ")
:effect (req (wait-for
(reveal state side (:hand corp))
(continue-ability state :runner (choose-cards (:hand corp) #{}) card nil)))}}}}))
{:on-play
{:trace
{:base 3
:req (req (some #{:hq :rd :archives} (:successful-run runner-reg)))
:unsuccessful
(with-revealed-hand :corp {:event-side :corp :forced true}
{:prompt "Shuffle up to 2 cards into HQ"
:player :runner
:choices {:req (req (and (corp? target)
(in-hand? target)))
:max (req (min 2 (count (:hand corp))))}
:msg (msg "shuffle " (enumerate-str (map :title targets)) " into R&D")
:effect (req (doseq [t targets]
(move state :corp t :deck))
(shuffle! state :corp :deck))})}}})

(defcard "Wildcat Strike"
{:on-play (choose-one-helper
Expand Down
17 changes: 17 additions & 0 deletions src/clj/game/core/def_helpers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
[game.core.play-instants :refer [async-rfg]]
[game.core.prompts :refer [clear-wait-prompt]]
[game.core.props :refer [add-counter]]
[game.core.revealing :refer [conceal-hand reveal-hand reveal-loud]]
[game.core.runs :refer [jack-out]]
[game.core.say :refer [system-msg system-say]]
[game.core.to-string :refer [card-str]]
Expand Down Expand Up @@ -342,6 +343,22 @@
:ability {:display-side side
:msg :cost}})

(defn with-revealed-hand
"Resolves an ability while a player has their hand revealed (so you can click cards in their hand)
You can set the side that triggers the reveal (event-side) and if it displays as a forced reveal
(forced) via the args"
([target-side abi] (with-revealed-hand target-side nil abi))
([target-side {:keys [event-side forced] :as args} abi]
{:async true
:effect (req
(wait-for (reveal-loud state (or event-side side) card args (get-in @state [target-side :hand]))
(if (get-in @state [target-side :openhand])
(continue-ability state side abi card targets)
(do (reveal-hand state target-side)
(wait-for (resolve-ability state side abi card targets)
(conceal-hand state target-side)
(effect-completed state side eid))))))}))

(defmacro defcard
[title ability]
`(do (swap! card-defs-cache dissoc ~title)
Expand Down

0 comments on commit 62a4126

Please sign in to comment.