                   (js/Math.sqrt 3)
                   (+ k (- j 2))))])
 
-(defn laser-shot [{:keys [start stop]} owner]
+(defn laser-shot [{:keys [start stop dmg direction]} owner]
   (html
    (let [[x_1 y_1] (coords-to-pixel start)
          [x_2 y_2] (coords-to-pixel stop)

  (:require-macros [cljs.core.async.macros :refer (go go-loop)])
  (:require [cljs.core.async :refer (<! chan close! map<)]
            [clojure.string :as str]
            [clojure.walk :refer [keywordize-keys]]
            [chord.client :as socket :refer (ws-ch)]
            [om.core :as om :include-macros true]

    "left-down"  [ 1  0]
    "right-down" [ 0  1]))

(defn length [[ax ay] [bx by]]
  (js/Math.sqrt
   (+ (js/Math.pow (- ax bx) 2)
      (js/Math.pow (- ay by) 2))))

(defn get-weapon [player weapon]
  (first
   (drop-while (comp (partial not= weapon) :name)
               (select-keys player
                            [:primary-weapon
                             :secondary-weapon]))))

(defmulti handle-action :type)

(defmethod handle-action "laser"
  [{:keys [from stop direction] :as action}]
  (let [player (player! from)
        level (:level (get-weapon player "laser"))]
    (swap! state assoc :action
           (assoc action
             :start (:position player)
             :stop (parse-coords stop)
             :dmg (+ 16 (* 2 (dec level)))))))

(defmethod handle-action "droid"
  [{:keys [sequence from] :as action}]
  (let [level (:level (get-weapon (player! from) "droid"))]
    (swap! state assoc :action
           (assoc action
             :sequence (mapv direction->coord
                             sequence)
             :dmg (+ 20 (* 2 level))))))

(defmethod handle-action "mortar"
  [{:keys [from coordinates :as action]}]
  (let [player (player! from)
        level (->> (select-keys player [:primary-weapon
                                        :secondary-weapon])
                   (drop-while (comp (partial not= "mortar") :name))
                   first
                   :level)]
    (swap! state assoc :action
           (assoc action
             :coord (mapv +
                          (:position player)
                          (parse-coords coordinates))
             :radius (inc level)
             :dmg (if (= 3 level) 25 20)))))

(defmethod handle-action "move"
  [{:keys [direction from]}]
