From fa4129a6428fd68808217acd6a29255b432252a9 Mon Sep 17 00:00:00 2001 From: John Warwick Date: Sat, 18 Aug 2018 16:55:31 -0400 Subject: [PATCH] Fix crash when changing number of tags --- src/clj/game/core/actions.clj | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/clj/game/core/actions.clj b/src/clj/game/core/actions.clj index 2637b03ae8..1d193e6801 100644 --- a/src/clj/game/core/actions.clj +++ b/src/clj/game/core/actions.clj @@ -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]}] @@ -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)])