Skip to content

Commit

Permalink
Merge pull request #7282 from butzopower/allow-undo-to-start-of-turn
Browse files Browse the repository at this point in the history
Allow /undo-click to go back multiple clicks
  • Loading branch information
NoahTheDuke authored Mar 18, 2024
2 parents 297d2b0 + 52bf452 commit baca0ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/clj/game/core/commands.clj
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@
(defn command-undo-click
"Resets the game state back to start of the click"
[state side]
(when-let [click-state (:click-state @state)]
(when-let [click-state (peek (:click-states @state))]
(when (= (:active-player @state) side)
(reset! state (assoc click-state :log (:log @state) :click-state click-state :run nil :history (:history @state)))
(reset! state (assoc click-state :log (:log @state) :click-states (pop (:click-states @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"))
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/core/costs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
[cost state side eid card actions]
(let [a (keep :action actions)]
(when (not (some #{:steal-cost} a))
(swap! state assoc :click-state (dissoc @state :log)))
(swap! state update :click-states conj (dissoc @state :log :history)))
(swap! state update-in [:stats side :lose :click] (fnil + 0) (value cost))
(deduct state side [:click (value cost)])
(wait-for (trigger-event-sync state side (make-eid state eid)
Expand Down
1 change: 1 addition & 0 deletions src/clj/game/core/turns.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

; Functions to set up state for undo-turn functionality
(doseq [s [:runner :corp]] (swap! state dissoc-in [s :undo-turn]))
(swap! state assoc :click-states [])
(swap! state assoc :turn-state (dissoc @state :log :turn-state))

(when (= side :corp)
Expand Down

0 comments on commit baca0ff

Please sign in to comment.