Skip to content

Commit

Permalink
Merge pull request #6983 from butzopower/undo-click-play-area
Browse files Browse the repository at this point in the history
Put cards back from play area after undoing a click
  • Loading branch information
NoahTheDuke authored Aug 4, 2023
2 parents a9e38e7 + bf8e5b8 commit 1500d65
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/clj/game/core/commands.clj
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@
(when-let [click-state (:click-state @state)]
(when (= (:active-player @state) side)
(reset! state (assoc click-state :log (:log @state) :click-state click-state :run nil :history (:history @state)))
(doseq [c (filter #(not (has-subtype? % "Lockdown")) (:play-area (side @state)))]
(move state side c (:previous-zone c) {:suppress-event true}))
(system-say state side (str "[!] " (if (= side :corp) "Corp" "Runner") " uses the undo-click command"))
(doseq [s [:runner :corp]]
(toast state s "Game reset to start of click")))))
Expand Down
24 changes: 24 additions & 0 deletions test/clj/game/core/actions_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@
(is (= 4 (:click (get-runner))) "Runner back to 4 clicks")
(is (= 5 (:credit (get-runner))) "Runner back to 5 credits")))

(deftest undo-click-return-card-from-play-area
(do-game
(new-game {:corp {:deck ["Predictive Planogram"]}
:runner {:deck ["Dirty Laundry"]}})
(play-from-hand state :corp "Predictive Planogram")
(core/command-undo-click state :corp)
(is (= 0 (count (:play-area (get-corp)))) "Corp play area is empty")
(is (= 1 (count (:hand (get-corp)))) "Corp has 1 card in HQ")
(take-credits state :corp)
(play-from-hand state :runner "Dirty Laundry")
(core/command-undo-click state :runner)
(is (= 0 (count (:play-area (get-runner)))) "Runner play area is empty")
(is (= 1 (count (:hand (get-runner)))) "Player has 1 card in grip")))

(deftest undo-click-does-not-return-lockdown-from-play-area
(do-game
(new-game {:corp {:deck ["NAPD Cordon" "Predictive Planogram"]}
:runner {:deck ["Dirty Laundry"]}})
(play-from-hand state :corp "NAPD Cordon")
(play-from-hand state :corp "Predictive Planogram")
(core/command-undo-click state :corp)
(is (= 1 (count (:play-area (get-corp)))) "Corp play area still has NAPD Cordon")
(is (= 1 (count (:hand (get-corp)))) "Corp has 1 card in HQ")))

(deftest undo-click-with-bioroid-cost
(do-game
(new-game {:corp {:deck [(qty "Hedge Fund" 5)]
Expand Down

0 comments on commit 1500d65

Please sign in to comment.