Browse Source

Move print-state to console namespace

Thomas Dy 8 years ago
parent
commit
0e900ee9fe
2 changed files with 18 additions and 16 deletions
  1. 15 0
      src/bombnet/console.clj
  2. 3 16
      src/bombnet/core.clj

+ 15 - 0
src/bombnet/console.clj

@@ -0,0 +1,15 @@
+(ns bombnet.console)
+
+(defn print-state [state]
+  (let [{:keys [board players bombs explosion]} state
+        coords (fn [{[x y] :pos}] [y x])
+        coords2 (fn [[x y]] [y x])
+        draw-players (fn [board] (reduce #(assoc-in % (coords %2) "@") board players))
+        draw-bombs (fn [board] (reduce #(assoc-in % (coords %2) "Q") board bombs))
+        draw-explosion (fn [board] (reduce #(assoc-in % (coords2 %2) "X") board explosion))
+        board2 (-> board
+                   draw-explosion
+                   draw-bombs
+                   draw-players)
+        string (reduce #(str % "\n" (reduce str %2)) "" board2)]
+    (println string)))

+ 3 - 16
src/bombnet/core.clj

@@ -1,23 +1,10 @@
 (ns bombnet.core
   (:gen-class)
-  (:require [bombnet.game :refer :all]))
-
-(defn print-state [state]
-  (let [{:keys [board players bombs explosion]} state
-        coords (fn [{[x y] :pos}] [y x])
-        coords2 (fn [[x y]] [y x])
-        draw-players (fn [board] (reduce #(assoc-in % (coords %2) "@") board players))
-        draw-bombs (fn [board] (reduce #(assoc-in % (coords %2) "Q") board bombs))
-        draw-explosion (fn [board] (reduce #(assoc-in % (coords2 %2) "X") board explosion))
-        board2 (-> board
-                   draw-explosion
-                   draw-bombs
-                   draw-players)
-        string (reduce #(str % "\n" (reduce str %2)) "" board2)]
-    (println string)))
+  (:require [bombnet.console :refer :all]
+            [bombnet.game :refer :all]))
 
 (defn -main
-  "I don't do a whole lot ... yet."
+  "I don't do a whole lot ... yet"
   [& args]
   (-> (new-game [{:id 1 :name "Thomas"}])
       (queue-action 1 {:type "bomb" :timer 1})