Skip to content

Commit

Permalink
extended play-with-prompt to take arbitrary number of options
Browse files Browse the repository at this point in the history
  • Loading branch information
NBKelly committed Feb 4, 2025
1 parent 3b7cb97 commit bf790bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/clj/game/cards/programs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@
:runner {:hand ["Chisel"]}})
(play-from-hand state :corp "Ice Wall" "HQ")
(take-credits state :corp)
(play-from-hand-with-prompt state :runner "Chisel" "Ice Wall")
(play-from-hand-with-prompts state :runner "Chisel" "Ice Wall")
(let [iw (get-ice state :hq 0)
chisel (first (:hosted (refresh iw)))]
(run-on state "HQ")
Expand Down Expand Up @@ -1890,7 +1890,7 @@
:runner {:hand ["Chisel" "Devil Charm"]}})
(play-from-hand state :corp "Ice Wall" "HQ")
(take-credits state :corp)
(play-from-hand-with-prompt state :runner "Chisel" "Ice Wall")
(play-from-hand-with-prompts state :runner "Chisel" "Ice Wall")
(play-from-hand state :runner "Devil Charm")
(let [iw (get-ice state :hq 0)
chisel (first (:hosted (refresh iw)))]
Expand Down
14 changes: 7 additions & 7 deletions test/clj/game/test_framework.clj
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@
([state side title server]
`(error-wrapper (play-from-hand-impl ~state ~side ~title ~server))))

(defn play-from-hand-with-prompt-impl
[state side title choice]
(defn play-from-hand-with-prompts-impl
[state side title choices]
(let [card (find-card title (get-in @state [side :hand]))]
(ensure-no-prompts state)
(is' (some? card) (str title "is in hand"))
Expand All @@ -587,14 +587,14 @@
(println title " was instead found in the opposing hand - was the wrong side used?")))
true)
(when-let [played (core/process-action "play" state side {:card card})]
(click-prompts state side choice)))))
(click-prompts-impl state side choices)))))

(defmacro play-from-hand-with-prompt
"Play a card from hand based on it's title, and then click a prompt
(defmacro play-from-hand-with-prompts
"Play a card from hand based on it's title, and then click any number of prompts
accepts for prompt: a string, a fn, a card object"
([state side title] `(play-from-hand ~state ~side ~title nil))
([state side title prompt]
`(error-wrapper (play-from-hand-with-prompt-impl ~state ~side ~title ~prompt))))
([state side title & prompts]
`(error-wrapper (play-from-hand-with-prompts-impl ~state ~side ~title ~(vec prompts)))))

;;; Run functions
(defn run-on-impl
Expand Down

0 comments on commit bf790bc

Please sign in to comment.