    (.getElementById js/document "app"))
   (go
    (loop []
-     (let [event (<! ch)]
+     (let [event (<! ch)
+           x (:x (:coords event))
+           y (:y (:coords event))]
        (println event)
         (case (:type event)
           :select-unit   (select-unit (:id event))
           :deselect-unit (deselect-unit)
           :move-unit     (do
-                           (move-unit   (:x (:coords event)) (:y (:coords event)))
+                           (move-unit x y)
                            (swap! game update-in [:actions] inc)
                            (deselect-unit)
                            (if (= (:actions @game) 2) (switch-turns)))
           :pickup-ball   (do
-                           (pickup-ball (:x (:coords event)) (:y (:coords event)))
+                           (pickup-ball x y)
+                           (swap! game update-in [:actions] inc)
+                           (deselect-unit)
+                           (if (= (:actions @game) 2) (switch-turns)))
+          :attack        (do
+                           (attack x y)
                            (swap! game update-in [:actions] inc)
                            (deselect-unit)
                            (if (= (:actions @game) 2) (switch-turns))))

  (cond
   (and
    (= nil (selected-unit))
    (unit? x y (:turn @game)))
   {:type   :select-unit
    :id     (:id (unit? x y (:turn @game)))
    :coords {:x x :y y}}

   (or
     (unit? x y (:turn @game))
     (not (in-range? x y (:id (selected-unit)))))
   {:type   :deselect-unit
    :id     (:id (unit? x y (:turn @game)))

    (swap! game assoc-in [:units (:turn @game)] (conj team updated-unit))))

(defn move-unit [x y]
  (let [selected-unit (selected-unit)
      updated-unit
      (conj
       selected-unit
       {:coords {:x x :y y}})
      team
      (filter #(not= selected-unit %) (active-team))]
    (swap! game assoc-in [:units (:turn @game)] (conj team updated-unit))))

(defn attack [x y]
  (let [selected-unit (selected-unit)
        updated-unit  (conj selected-unit {:ball false})
        defense-unit  (unit? x y (defense))
        team          (filter #(not= selected-unit %) (active-team))]
    (do
      (swap! game assoc-in [:units (:turn @game)] (conj team updated-unit))
      (println "Attack: " (rand-int 8) "Defense: " (rand-int 8)))))

(defn ball-in-front-of-unit? [ball unit]
  (let [ball-x (:x (:coords ball))
