   "Error loading action"
   []
   (state/set-state :processing-action nil))
+
+(defn- deploy-game
+  "Deploys a game"
+  [ev]
+  (let [actions (or (state/get-state :current-actions) [])
+        game (state/get-state :original-game-data)
+        player-code (get-in game ["viewed-by" "player-code"])
+        token (state/get-state :token)
+        game-id (state/get-state :game-id)
+        url (str "http://api.orionsbelt.eu/game/" game-id "/deploy?token=" token)]
+    (state/set-state :processing-action actions)
+    (PUT url {:params {:actions actions}
+              :format :json
+              :handler action-added
+              :error-handler error-loading-action})))
 
 (defn- add-action
   "Processes a new action"

    (dom/input #js {:type "text" :id "newAction" :className "form-control"})
    (dom/button #js {:id "resetActionButton" :onClick reset-actions :className "btn btn-default"} "Reset")
    (dom/button #js {:id "addActionButton" :onClick add-action :className "btn btn-info" :disabled (add-action-disabled state)} "Add")
    (dom/button #js {:id "deployButton" :onClick add-action :className "btn btn-info" :disabled (deploy-disabled state)} "Deploy")))

(defn- render-game
  "Renders the index page"

(ns battle-console.game
  (:require [battle-console.state :as state]
            [ajax.core :refer [GET POST, PUT]]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [cljs.reader :as reader]
