   (let [token (state/get-state :token)
         url (str "http://api.orionsbelt.eu/game/" (params :id) "?token=" token)]
     (state/set-state :loading-game (str "Loading game " (params :id) "..."))
+    (state/set-state :game-id (params :id))
     (GET url {:handler game-loaded
               :error-handler error-loading})))
 

(defn- get-stash
  "Gets the current stash"
  [game]
  (println game)
  (if (empty? (get-in game ["battle" "stash" "p1"]))
    (get-in game ["battle" "stash" "p2"])
    (get-in game ["battle" "stash" "p1"])))

(defn- game-stash
  "Shows the current stash if available"

  "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"
