 (enable-console-print!)
 
 (defonce app-state (atom nil))
+(defonce names (atom {:black nil :blue nil :green nil :orange nil :red nil}))
+
+(defn set-name! [color name]
+  (swap! names assoc color name))
+
+(defn get-name [color]
+  (color @names))
 
 (defn to-scale [n]
   (* 1.65 n))

   [:h1 "CARTAGENA"]
   [:div
    [:button
     {:class "button"
      :on-click (fn button-click [e]
                  (new-game!))}
     "New Game"]]
   (when (and @app-state (:game-over @app-state))
     [:div
      [:h2 "WE HAVE A WINNER!"]
      [:h3 (str "Congratulations, " (:name (active-player @app-state)) "!")]])
   [:div
    {:style {:float "left" :margin-left 10 :margin-right 10}}
    (-> [:svg

  (reset! app-state response))

(defn new-game! []
  (let [players (cond-> []
                        (get-name :black) (conj {:name (get-name :black) :color :black})
                        (get-name :blue) (conj {:name (get-name :blue) :color :blue})
                        (get-name :green) (conj {:name (get-name :green) :color :green})
                        (get-name :orange) (conj {:name (get-name :orange) :color :orange})
                        (get-name :red) (conj {:name (get-name :red) :color :red})
                        )]
  (reset! app-state (dissoc @app-state :select-players))
  (ajax/POST "http://localhost:3000/new-game"
             {:params {:players players}
              :handler on-new-game
              :error-handler on-error})))

(defn select-players! []
  (reset! app-state (assoc @app-state :select-players true)))

(defn on-update-active-player [response]
  (reset! app-state (assoc @app-state :actions-remaining (:actions-remaining response)
