From 7ca348442d9c4ccfd620bca694d7a23173db19eb Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Mon, 18 Mar 2013 22:02:16 -0400 Subject: [PATCH] Add update-gs, which always returns the modified gs and is almost always what you want. --- src/hottub/gs.clj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hottub/gs.clj b/src/hottub/gs.clj index afdcb53..2fe9690 100644 --- a/src/hottub/gs.clj +++ b/src/hottub/gs.clj @@ -14,6 +14,9 @@ (defmacro with-gs [gs & body] `(binding [*gamestate* (ref ~gs)] (dosync ~@body))) +(defmacro update-gs [& body] + `(with-gs ~@body (get-gs))) + (defn get-gs [] @*gamestate*) (defn entity-in [gamestate id] (get-in gamestate [:entities id])) @@ -80,4 +83,4 @@ (defmethod query-index indextype [indextype index query] (or (get index query) #{})))) (define-id-index :name) -(define-id-index :type) +(define-id-index :type) \ No newline at end of file