 
 (defn estream-handler [k r os ns]
   (println k))
-  
+
+(check-fields (calc-state))
+
 (defn ws-handler [req]
   (with-channel req channel
     (on-close channel (fn [status]

    
    (add-watch estream :estream estream-handler)
    
    (send! channel (pr-str (calc-state @estream)))
    
    (on-receive channel (fn [data]
                          (let [parsed (edn/read-string data)
                                new-state (calc-state @estream)
                                cf (check-fields new-state)
                                new-state (calc-state @estream)]
                            (if (= :reset parsed)
                              (reset-game)
                              (swap! estream conj parsed))
                            (doseq [chan @connections]
                              (send! chan (pr-str new-state))))))))

(defroutes pr-routes
  (GET "/ws" [] ws-handler))

(defmethod transition :default [etype state & _]
  state)

(defn calc-state []
  (reduce 
    (fn [state [etype & eargs]]
      (transition etype state eargs))
