    (<=
     (reduce
      +
-     (map distance (vals target) (vals selected)))
+     (map distance (vals target) (vals (:coords selected))))
     move-range)))
+
+(defn action-type [owner target]
+  (let [selected (om/get-state owner :selected-unit)]
+
+    (cond
+     (and
+       (= nil selected)
+       (unit? (:turn @app-state) target))
+     :select-unit
+
+     (unit? :balls target)
+     :pickup-ball
+
+     (in-range? target selected)
+     :move-unit
+
+
+     (or
+       (unit? (:turn @app-state) target)
+       (not (in-range? target selected)))
+     :deselect-unit
+
+
+     )))
+
+(defn tile-view [cursor owner]
+  (reify
+    om/IRenderState
+    (render-state [this {:keys [coords actions] :as unit}]
+      (dom/td #js {:onClick
+                   #(put!
+                     actions
+                     {:coords coords
+                      :type (action-type owner coords)})}
+        (if-let [ball (unit? :balls coords)]
+          (dom/div #js {:className "ball"}))
+        (if-let [red-player (unit? :red-team coords)]
+          (dom/div
+           #js {
+           :className (str "red-team" " " (select-class owner unit))}))
+        (if-let [blue-player (unit? :blue-team coords)]
+          (dom/div
+           #js {
+           :className (str "blue-team" " " (select-class owner unit))}))))))
 
 (defn turn-view [data owner]
   (reify

            (apply dom/tr #js {:className (border-top y)}
              (vec (for [x board-length]
                (om/build tile-view app
                  {:state {:selected-unit (om/get-state owner :selected-unit) :actions actions :coords {:x x :y y}}})))))))
        (bench)))))

(om/root board-view app-state


    om/IWillMount
    (will-mount [_]
    (handle-action app owner (om/get-state owner :actions)))

    om/IRenderState
    (render-state [this {:keys [actions]}]
