   [:ul
    (map (fn [player] ^{:key player} [:li (:name player)]) (parse-json @players))])
 
+(def player1 (atom ""))
+(def player2 (atom ""))
+
+(defn both-players-selected? []
+  (and (not= @player1 "")
+       (not= @player2 "")))
+
 (defn home-page []
   [:div [:h2 "Dartflow"]
    [:ul
-    [:li [:a {:href "#/new-game"} "New match"]]
+    [:li [:a {:href "#/select-players"} "New match"]]
     [:li [:a {:href "#/standings"} "Standings"]]]])
 
-(defn new-game-page []
+(def game (atom {}))
+
+(defn select-game-type-page []
+  [:div
+   (println @game)
+   "HELLO"])
+
+(defn select-players-page []
   (load-players)
   [:div
    [:a {:href "#"} "Home"]
    [:div [:h2 "New game"]
-    [:a {:href "#/new-player"} "New player"]
-    [:h3 "Select two players"]
     [:ul
-     (doall
-      (map (fn [{:keys [name]}]
-             ^{:key name}
-             [:li [:input {:type "checkbox"
-                           :disabled (and (= (count @selected-players)
-                                             2)
-                                          (not (@selected-players name)))
+     [:li "Player 1: "
+      [:span {:on-click #(reset! player1 "")} @player1]]
+     [:li "Player 2: "
+      [:span {:on-click #(reset! player2 "")} @player2]]]
 
-                           :on-click (fn []
-                                       (if (@selected-players name)
-                                         (swap! selected-players difference #{name})
-                                         (swap! selected-players conj name)))}
-                   name]])
-           (parse-json @players)))]]])
+    (when (both-players-selected?)
+      [:div
+       [:button {:on-click (fn []
+                             (reset! player1 "")
+                             (reset! player2 ""))} "Reset"]
+       [:button {:on-click (fn []
+                             (swap! game #(assoc %1
+                                                 :player1 %2
+                                                 :player2 %3) @player1 @player2)
+                             (redirect-to "#/select-game-type"))} "Confirm"]])
+    (let [select-fn (fn [player]
+                      [:ul
+                       (doall
+                        (map (fn [{:keys [name]}]
+                               (when (and (not= name @player1)
+                                          (not= name @player2))
+                                 ^{:key name}
+                                 [:li [:button {:on-click (fn []
+                                                            (reset! player name))}
+                                       name]]))
+                             (parse-json @players)))]
+                      )]
+      (if (= "" @player1)
+        (select-fn player1)
+        (select-fn player2)))
 
-(defn redirect-to [path]
-  (set! js/window.location.href path))
+    [:a {:href "#/new-player"} "New player"]]])
+
+
 
 (defn new-player-page []
   (let [val (atom "")]

;; -------------------------
;; Views

(def db (atom {:players #{{:name "Steven"}
                          {:name "Davide"}}
               :matches []}))

(defonce players (atom nil))
(def selected-players (atom #{}))

(defn add-new-player [name]
  (swap! db #(update-in % [:players] conj {:name name})))

(defn parse-json [json]
  (walk/keywordize-keys (t/read (t/reader :json) @players)))

                :placeholder "New player name"}]
       [:button {:on-click (fn []
                             (POST (str "/add-player/" @val))
                             (redirect-to "#/select-players"))} "Save"]])))

(defn current-page []
  [:div [(session/get :current-page)]])
