Skip to content

Commit 57c735b

Browse files
authored
Merge pull request #8456 from NBKelly/unit-test-update
Add rez to `play-cards`
2 parents 6e1b59a + fc7e3d0 commit 57c735b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

test/clj/game/cards/ice_test.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6305,6 +6305,12 @@
63056305
(fire-subs state png1)
63066306
(is (not (:run @state)) "Run ended"))))
63076307

6308+
(deftest ping-no-tag-outside-of-run
6309+
(do-game
6310+
(new-game {:corp {:hand ["Ping"]}})
6311+
(play-cards state :corp ["Ping" "HQ" :rezzed])
6312+
(is (zero? (count-tags state)) "Did not take a tag")))
6313+
63086314
(deftest piranhas-take-bad-pub
63096315
(do-game
63106316
(new-game {:corp {:hand ["Piranhas"]

test/clj/game/test_framework.clj

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[game.core.card :refer [active? get-card get-counters get-title installed?
1010
rezzed?]]
1111
[game.core.eid :as eid]
12+
[game.core.events :refer [turn-events]]
1213
[game.core.ice :refer [active-ice?]]
1314
[game.core.initializing :refer [make-card]]
1415
[game.core.threat :refer [threat-level]]
@@ -616,6 +617,17 @@
616617
([state side title server]
617618
`(error-wrapper (play-from-hand-impl ~state ~side ~title ~server))))
618619

620+
(defn- split-on-keywords [coll]
621+
(reduce (fn [acc x]
622+
(if (keyword? x)
623+
(conj acc x)
624+
(let [last-el (peek acc)]
625+
(if (vector? last-el)
626+
(conj (pop acc) (conj last-el x))
627+
(conj acc [x])))))
628+
[]
629+
coll))
630+
619631
(defn play-from-hand-with-prompts-impl
620632
[state side title choices]
621633
(let [card (find-card title (get-in @state [side :hand]))]
@@ -627,7 +639,20 @@
627639
(println title " was instead found in the opposing hand - was the wrong side used?")))
628640
true)
629641
(when-let [played (core/process-action "play" state side {:card card})]
630-
(click-prompts-impl state side choices)))))
642+
(let [choice-sets (split-on-keywords choices)]
643+
(doseq [cs choice-sets]
644+
(cond
645+
(vector? cs) (click-prompts-impl state side cs)
646+
(#{:rez :rezzed} cs)
647+
(if-let [tgt (->> (turn-events state side :corp-install)
648+
(apply concat)
649+
(map :card)
650+
(filter #(= (:title %) title))
651+
(filter (complement rezzed?))
652+
last)]
653+
(core/process-action "rez" state :corp {:card tgt})
654+
(throw (Exception. (str title " not found in an unrezzed state to be rezzed")))))))))))
655+
631656

632657
(defmacro play-from-hand-with-prompts
633658
"Play a card from hand based on it's title, and then click any number of prompts

0 commit comments

Comments
 (0)