Skip to content

Commit

Permalink
Fix crash when changing number of tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jwarwick committed Aug 18, 2018
1 parent 50a0d6a commit fa4129a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/clj/game/core/actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
(str "sets unused MU to " (available-mu state)
" (" (if (pos? delta) (str "+" delta) delta) ")")))

(defn- change-tags
"Change a player's base tag count"
[state delta]
(if (neg? delta)
(deduct state :runner [:tag (Math/abs delta)])
(gain state :runner :tag delta))
(system-msg state :runner
(str "sets Tags to " (get-in @state [:runner :tag :base])
" (" (if (pos? delta) (str "+" delta) delta) ")")))

(defn change
"Increase/decrease a player's property (clicks, credits, MU, etc.) by delta."
[state side {:keys [key delta]}]
Expand All @@ -83,6 +93,10 @@
(= :hand-size key)
(change-map state side key delta)

;; Tags need special treatment since they are a more complex map
(= :tag key)
(change-tags state delta)

:else
(do (if (neg? delta)
(deduct state side [key (- delta)])
Expand Down

0 comments on commit fa4129a

Please sign in to comment.