3152de9c4d38

Minor refactorings suggested by Gery Debongnie.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 13 Oct 2012 14:55:32 -0400
parents f15b8173a124
children 572404588054
branches/tags (none)
files src/caves/core.clj src/caves/ui/drawing.clj src/caves/utils.clj

Changes

--- a/src/caves/core.clj	Sat Sep 01 23:18:31 2012 -0400
+++ b/src/caves/core.clj	Sat Oct 13 14:55:32 2012 -0400
@@ -23,12 +23,15 @@
 (defn run-game [game screen]
   (loop [{:keys [input uis] :as game} game]
     (when (seq uis)
-      (if (nil? input)
-        (let [game (update-in game [:world] tick-all)
-              _ (draw-game game screen)
-              game (clear-messages game)]
-          (recur (get-input game screen)))
-        (recur (process-input (dissoc game :input) input))))))
+      (recur (if input
+               (-> game
+                 (dissoc :input)
+                 (process-input input))
+               (-> game
+                 (update-in [:world] tick-all)
+                 (draw-game screen)
+                 (clear-messages)
+                 (get-input screen)))))))
 
 (defn new-game []
   (->Game nil [(->UI :start)] nil {:show-regions false}))
--- a/src/caves/ui/drawing.clj	Sat Sep 01 23:18:31 2012 -0400
+++ b/src/caves/ui/drawing.clj	Sat Oct 13 14:55:32 2012 -0400
@@ -153,4 +153,5 @@
   (s/clear screen)
   (doseq [ui (:uis game)]
     (draw-ui ui game screen))
-  (s/redraw screen))
+  (s/redraw screen)
+  game)
--- a/src/caves/utils.clj	Sat Sep 01 23:18:31 2012 -0400
+++ b/src/caves/utils.clj	Sat Oct 13 14:55:32 2012 -0400
@@ -28,4 +28,4 @@
 
 
 (defn enumerate [s]
-  (map vector (iterate inc 0) s))
+  (map-indexed vector s))