From 772896ae1c203c76bb45fd10deccb34834e5c4f2 Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Thu, 11 Feb 2016 22:20:31 +0100 Subject: [PATCH 1/9] fancypants help formatting --- src/cljs/netrunner/help.cljs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cljs/netrunner/help.cljs b/src/cljs/netrunner/help.cljs index f5074f2a18..fa1827e4a3 100644 --- a/src/cljs/netrunner/help.cljs +++ b/src/cljs/netrunner/help.cljs @@ -149,12 +149,12 @@ "the influence printed on the ID by 1, with a minimum of 1 (so Professor is unaffected). For " "more information about the MWL read Tournament Rules from " [:a {:href "https://www.fantasyflightgames.com/en/products/android-netrunner-the-card-game/"} "the official FFG page"] "."] - [:p "Decks that are valid and fit within tournament restrictions are marked \"Tournament legal\". " + [:p "Decks that are valid and fit within tournament restrictions are marked " [:span.legal "Tournament legal" ] ". " "Decks that fit within the printed influence limit, but not within the tournament restrictions, " - "are marked \"Casual play only\". Decks that do not fit basic deckbuilding rules are marked \"Invalid\"."] + "are marked " [:span.casual "Casual play only"] ". Decks that do not fit basic deckbuilding rules are marked " [:span.invalid "Invalid"] "."] [:p "Putting cards in your deck that are not yet available for sale (i.e. future spoilers) or ones that are " - "out of competetive rotation will also result in your deck being marked as casual. Such cards " - "should be easy to identify - they are highlighted in the deckbuilder."])} + "out of competetive rotation will also result in your deck being marked as " [:span.casual "Casual play only"] ". Such cards " + "should be easy to identify - they are " [:span.casual "highlighted"] " in the deckbuilder."])} {:id "rezaccess" :title "How do I rez cards as Corp in the 4.3 run timing window?" :content [:p "Sadly, this window is currently unimplemented - you need to ask the Runner manually. " From 004010831853ed41237ba34ac1cba8d200bf49d5 Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Thu, 11 Feb 2016 22:25:11 +0100 Subject: [PATCH 2/9] moved game-list to separate function --- src/cljs/netrunner/gamelobby.cljs | 37 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/cljs/netrunner/gamelobby.cljs b/src/cljs/netrunner/gamelobby.cljs index fcbf22b3cb..d7936743b6 100644 --- a/src/cljs/netrunner/gamelobby.cljs +++ b/src/cljs/netrunner/gamelobby.cljs @@ -180,6 +180,25 @@ [:input {:ref "msg-input" :placeholder "Say something" :accessKey "l"}] [:button "Send"]]]])))) +(defn game-list [{:keys [games gameid] :as cursor} owner] + [:div.game-list + (if (empty? games) + [:h4 "No game"] + (for [game games] + [:div.gameline {:class (when (= gameid (:gameid game)) "active")} + (when-not (or gameid (= (count (:players game)) 2) (:started game)) + (let [id (:gameid game)] + [:button {:on-click #(join-game id owner)} "Join"])) + (when (and (:allowspectator game) (not gameid)) + (let [id (:gameid game)] + [:button {:on-click #(watch-game id owner)} "Watch"])) + (let [c (count (:spectators game))] + [:h4 (str (:title game) + (when (pos? c) + (str " (" c " spectator" (when (> c 1) "s") ")")))]) + [:div + (om/build-all player-view (:players game))]]))]) + (defn game-lobby [{:keys [games gameid messages user] :as cursor} owner] (reify om/IRenderState @@ -191,23 +210,7 @@ (if gameid [:button {:class "disabled"} "New game"] [:button {:on-click #(new-game cursor owner)} "New game"])] - [:div.game-list - (if (empty? games) - [:h4 "No game"] - (for [game games] - [:div.gameline {:class (when (= gameid (:gameid game)) "active")} - (when-not (or gameid (= (count (:players game)) 2) (:started game)) - (let [id (:gameid game)] - [:button {:on-click #(join-game id owner)} "Join"])) - (when (and (:allowspectator game) (not gameid)) - (let [id (:gameid game)] - [:button {:on-click #(watch-game id owner)} "Watch"])) - (let [c (count (:spectators game))] - [:h4 (str (:title game) - (when (pos? c) - (str " (" c " spectator" (when (> c 1) "s") ")")))]) - [:div - (om/build-all player-view (:players game))]]))]] + (game-list cursor owner)] [:div.game-panel (if (:editing state) From f63bc69ec19bacddf12dbb2b52658103b4467d28 Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Thu, 11 Feb 2016 22:26:46 +0100 Subject: [PATCH 3/9] swapped Watch and Join buttons to avoid accidental Watch when Join disappears --- src/cljs/netrunner/gamelobby.cljs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cljs/netrunner/gamelobby.cljs b/src/cljs/netrunner/gamelobby.cljs index d7936743b6..e91d77a56f 100644 --- a/src/cljs/netrunner/gamelobby.cljs +++ b/src/cljs/netrunner/gamelobby.cljs @@ -186,12 +186,12 @@ [:h4 "No game"] (for [game games] [:div.gameline {:class (when (= gameid (:gameid game)) "active")} - (when-not (or gameid (= (count (:players game)) 2) (:started game)) - (let [id (:gameid game)] - [:button {:on-click #(join-game id owner)} "Join"])) (when (and (:allowspectator game) (not gameid)) (let [id (:gameid game)] [:button {:on-click #(watch-game id owner)} "Watch"])) + (when-not (or gameid (= (count (:players game)) 2) (:started game)) + (let [id (:gameid game)] + [:button {:on-click #(join-game id owner)} "Join"])) (let [c (count (:spectators game))] [:h4 (str (:title game) (when (pos? c) From 9518b52440da47683fc93cec863db36f644845e2 Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Thu, 11 Feb 2016 23:33:25 +0100 Subject: [PATCH 4/9] Working casual and competitive lobby implementation. --- server.coffee | 2 +- src/cljs/netrunner/deckbuilder.cljs | 2 +- src/cljs/netrunner/gamelobby.cljs | 48 +++++++++++++++++------------ src/cljs/netrunner/help.cljs | 2 +- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/server.coffee b/server.coffee index 9c6ef8a0ce..deb6d15a34 100644 --- a/server.coffee +++ b/server.coffee @@ -120,7 +120,7 @@ lobby = io.of('/lobby').on 'connection', (socket) -> switch msg.action when "create" gameid = uuid.v1() - game = {date: new Date(), gameid: gameid, title: msg.title, allowspectator: msg.allowspectator,\ + game = {date: new Date(), gameid: gameid, title: msg.title, allowspectator: msg.allowspectator, lobby: msg.lobby,\ players: [{user: socket.request.user, id: socket.id, side: msg.side}], spectators: []} games[gameid] = game socket.join(gameid) diff --git a/src/cljs/netrunner/deckbuilder.cljs b/src/cljs/netrunner/deckbuilder.cljs index f82db4fd98..56379daf0f 100644 --- a/src/cljs/netrunner/deckbuilder.cljs +++ b/src/cljs/netrunner/deckbuilder.cljs @@ -255,7 +255,7 @@ (<= min (agenda-points deck) (inc min)))))) (defn released? - "Returns false if the card comes from a spoiled set or is out of competetive rotation." + "Returns false if the card comes from a spoiled set or is out of competitive rotation." [card] (let [cid (js/parseInt (:code card))] ;; Cards up to Kala Ghoda are currently released diff --git a/src/cljs/netrunner/gamelobby.cljs b/src/cljs/netrunner/gamelobby.cljs index e91d77a56f..8923d18b5a 100644 --- a/src/cljs/netrunner/gamelobby.cljs +++ b/src/cljs/netrunner/gamelobby.cljs @@ -79,7 +79,8 @@ (swap! app-state assoc :messages []) (send {:action "create" :title (om/get-state owner :title) :allowspectator (om/get-state owner :allowspectator) - :side (om/get-state owner :side)})))))) + :side (om/get-state owner :side) + :lobby (om/get-state owner :current-lobby)})))))) (defn join-game [gameid owner] (authenticated @@ -181,26 +182,30 @@ [:button "Send"]]]])))) (defn game-list [{:keys [games gameid] :as cursor} owner] - [:div.game-list - (if (empty? games) - [:h4 "No game"] - (for [game games] - [:div.gameline {:class (when (= gameid (:gameid game)) "active")} - (when (and (:allowspectator game) (not gameid)) - (let [id (:gameid game)] - [:button {:on-click #(watch-game id owner)} "Watch"])) - (when-not (or gameid (= (count (:players game)) 2) (:started game)) - (let [id (:gameid game)] - [:button {:on-click #(join-game id owner)} "Join"])) - (let [c (count (:spectators game))] - [:h4 (str (:title game) - (when (pos? c) - (str " (" c " spectator" (when (> c 1) "s") ")")))]) - [:div - (om/build-all player-view (:players game))]]))]) + (let [lobbygames (filter #(= (:lobby %) (om/get-state owner :current-lobby)) games)] + [:div.game-list + (if (empty? lobbygames) + [:h4 "No games"] + (for [game lobbygames] + [:div.gameline {:class (when (= gameid (:gameid game)) "active")} + (when (and (:allowspectator game) (not gameid)) + (let [id (:gameid game)] + [:button {:on-click #(watch-game id owner)} "Watch"])) + (when-not (or gameid (= (count (:players game)) 2) (:started game)) + (let [id (:gameid game)] + [:button {:on-click #(join-game id owner)} "Join"])) + (let [c (count (:spectators game))] + [:h4 (str (:title game) + (when (pos? c) + (str " (" c " spectator" (when (> c 1) "s") ")")))]) + [:div (om/build-all player-view (:players game))]]))])) (defn game-lobby [{:keys [games gameid messages user] :as cursor} owner] (reify + om/IInitState + (init-state [this] + {:current-lobby "Casual"}) + om/IRenderState (render-state [this state] (sab/html @@ -209,7 +214,12 @@ [:div.button-bar (if gameid [:button {:class "disabled"} "New game"] - [:button {:on-click #(new-game cursor owner)} "New game"])] + [:button {:on-click #(new-game cursor owner)} "New game"]) + [:div.float-right "Lobby: " + [:select {:value (om/get-state owner :current-lobby) + :on-change #(om/set-state! owner :current-lobby (.. % -target -value))} + [:option "Casual"] + [:option "Competitive"]]]] (game-list cursor owner)] [:div.game-panel diff --git a/src/cljs/netrunner/help.cljs b/src/cljs/netrunner/help.cljs index fa1827e4a3..98ca91eefd 100644 --- a/src/cljs/netrunner/help.cljs +++ b/src/cljs/netrunner/help.cljs @@ -153,7 +153,7 @@ "Decks that fit within the printed influence limit, but not within the tournament restrictions, " "are marked " [:span.casual "Casual play only"] ". Decks that do not fit basic deckbuilding rules are marked " [:span.invalid "Invalid"] "."] [:p "Putting cards in your deck that are not yet available for sale (i.e. future spoilers) or ones that are " - "out of competetive rotation will also result in your deck being marked as " [:span.casual "Casual play only"] ". Such cards " + "out of competitive rotation will also result in your deck being marked as " [:span.casual "Casual play only"] ". Such cards " "should be easy to identify - they are " [:span.casual "highlighted"] " in the deckbuilder."])} {:id "rezaccess" :title "How do I rez cards as Corp in the 4.3 run timing window?" From 500daf9ec63997302df879d794b57d3d3a5a368e Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Thu, 11 Feb 2016 23:40:49 +0100 Subject: [PATCH 5/9] added game count to the lobby options --- src/cljs/netrunner/gamelobby.cljs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cljs/netrunner/gamelobby.cljs b/src/cljs/netrunner/gamelobby.cljs index 8923d18b5a..c8aaf5dbc0 100644 --- a/src/cljs/netrunner/gamelobby.cljs +++ b/src/cljs/netrunner/gamelobby.cljs @@ -204,7 +204,7 @@ (reify om/IInitState (init-state [this] - {:current-lobby "Casual"}) + {:current-lobby "casual"}) om/IRenderState (render-state [this state] @@ -218,8 +218,8 @@ [:div.float-right "Lobby: " [:select {:value (om/get-state owner :current-lobby) :on-change #(om/set-state! owner :current-lobby (.. % -target -value))} - [:option "Casual"] - [:option "Competitive"]]]] + [:option {:value "casual"} (str "Casual (" (count (filter #(= "casual" (:lobby %)) games)) ")")] + [:option {:value "competitive"} (str "Competitive (" (count (filter #(= "competitive" (:lobby %)) games)) ")")]]]] (game-list cursor owner)] [:div.game-panel From 95fb5ae575d7efd6c59f4036c352a2bbc0b7204d Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Thu, 11 Feb 2016 23:46:35 +0100 Subject: [PATCH 6/9] some CSS to prevent lobby select from changing size when number of games changes --- src/cljs/netrunner/gamelobby.cljs | 2 +- src/css/base.styl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cljs/netrunner/gamelobby.cljs b/src/cljs/netrunner/gamelobby.cljs index c8aaf5dbc0..6039512ec7 100644 --- a/src/cljs/netrunner/gamelobby.cljs +++ b/src/cljs/netrunner/gamelobby.cljs @@ -216,7 +216,7 @@ [:button {:class "disabled"} "New game"] [:button {:on-click #(new-game cursor owner)} "New game"]) [:div.float-right "Lobby: " - [:select {:value (om/get-state owner :current-lobby) + [:select.lobbies {:value (om/get-state owner :current-lobby) :on-change #(om/set-state! owner :current-lobby (.. % -target -value))} [:option {:value "casual"} (str "Casual (" (count (filter #(= "casual" (:lobby %)) games)) ")")] [:option {:value "competitive"} (str "Competitive (" (count (filter #(= "competitive" (:lobby %)) games)) ")")]]]] diff --git a/src/css/base.styl b/src/css/base.styl index 50e1c0b192..ac4da7ef01 100644 --- a/src/css/base.styl +++ b/src/css/base.styl @@ -948,6 +948,9 @@ nav ul box-sizing: initial padding: 0 15px 15px + .lobbies + min-width: 145px + .game-list padding: 0 15px overflow: auto From ba56e45bf246933cfd43e11c83373316b4d6e040 Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Fri, 12 Feb 2016 00:47:28 +0100 Subject: [PATCH 7/9] used a DRYer on the lobby select code --- src/cljs/netrunner/gamelobby.cljs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cljs/netrunner/gamelobby.cljs b/src/cljs/netrunner/gamelobby.cljs index 6039512ec7..644c10132c 100644 --- a/src/cljs/netrunner/gamelobby.cljs +++ b/src/cljs/netrunner/gamelobby.cljs @@ -216,10 +216,11 @@ [:button {:class "disabled"} "New game"] [:button {:on-click #(new-game cursor owner)} "New game"]) [:div.float-right "Lobby: " - [:select.lobbies {:value (om/get-state owner :current-lobby) - :on-change #(om/set-state! owner :current-lobby (.. % -target -value))} - [:option {:value "casual"} (str "Casual (" (count (filter #(= "casual" (:lobby %)) games)) ")")] - [:option {:value "competitive"} (str "Competitive (" (count (filter #(= "competitive" (:lobby %)) games)) ")")]]]] + (let [count-games (fn [lobby] (count (filter #(= lobby (:lobby %)) games)))] + [:select.lobbies {:value (om/get-state owner :current-lobby) + :on-change #(om/set-state! owner :current-lobby (.. % -target -value))} + [:option {:value "casual"} (str "Casual (" (count-games "casual") ")")] + [:option {:value "competitive"} (str "Competitive (" (count-games "competitive") ")")]])]] (game-list cursor owner)] [:div.game-panel From e1b77dc0c66a397603fce2103419bd85a91ae055 Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Fri, 12 Feb 2016 08:50:49 +0100 Subject: [PATCH 8/9] Changed usage of 'lobby' to more correct 'room' --- server.coffee | 2 +- src/cljs/netrunner/gamelobby.cljs | 18 +++++++++--------- src/css/base.styl | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server.coffee b/server.coffee index deb6d15a34..d388e97ee8 100644 --- a/server.coffee +++ b/server.coffee @@ -120,7 +120,7 @@ lobby = io.of('/lobby').on 'connection', (socket) -> switch msg.action when "create" gameid = uuid.v1() - game = {date: new Date(), gameid: gameid, title: msg.title, allowspectator: msg.allowspectator, lobby: msg.lobby,\ + game = {date: new Date(), gameid: gameid, title: msg.title, allowspectator: msg.allowspectator, room: msg.room,\ players: [{user: socket.request.user, id: socket.id, side: msg.side}], spectators: []} games[gameid] = game socket.join(gameid) diff --git a/src/cljs/netrunner/gamelobby.cljs b/src/cljs/netrunner/gamelobby.cljs index 644c10132c..f7776ef44d 100644 --- a/src/cljs/netrunner/gamelobby.cljs +++ b/src/cljs/netrunner/gamelobby.cljs @@ -80,7 +80,7 @@ (send {:action "create" :title (om/get-state owner :title) :allowspectator (om/get-state owner :allowspectator) :side (om/get-state owner :side) - :lobby (om/get-state owner :current-lobby)})))))) + :room (om/get-state owner :current-room)})))))) (defn join-game [gameid owner] (authenticated @@ -182,11 +182,11 @@ [:button "Send"]]]])))) (defn game-list [{:keys [games gameid] :as cursor} owner] - (let [lobbygames (filter #(= (:lobby %) (om/get-state owner :current-lobby)) games)] + (let [roomgames (filter #(= (:room %) (om/get-state owner :current-room)) games)] [:div.game-list - (if (empty? lobbygames) + (if (empty? roomgames) [:h4 "No games"] - (for [game lobbygames] + (for [game roomgames] [:div.gameline {:class (when (= gameid (:gameid game)) "active")} (when (and (:allowspectator game) (not gameid)) (let [id (:gameid game)] @@ -204,7 +204,7 @@ (reify om/IInitState (init-state [this] - {:current-lobby "casual"}) + {:current-room "casual"}) om/IRenderState (render-state [this state] @@ -215,10 +215,10 @@ (if gameid [:button {:class "disabled"} "New game"] [:button {:on-click #(new-game cursor owner)} "New game"]) - [:div.float-right "Lobby: " - (let [count-games (fn [lobby] (count (filter #(= lobby (:lobby %)) games)))] - [:select.lobbies {:value (om/get-state owner :current-lobby) - :on-change #(om/set-state! owner :current-lobby (.. % -target -value))} + [:div.float-right "Room: " + (let [count-games (fn [room] (count (filter #(= room (:room %)) games)))] + [:select.rooms {:value (om/get-state owner :current-room) + :on-change #(om/set-state! owner :current-room (.. % -target -value))} [:option {:value "casual"} (str "Casual (" (count-games "casual") ")")] [:option {:value "competitive"} (str "Competitive (" (count-games "competitive") ")")]])]] (game-list cursor owner)] diff --git a/src/css/base.styl b/src/css/base.styl index ac4da7ef01..05f0242df0 100644 --- a/src/css/base.styl +++ b/src/css/base.styl @@ -948,7 +948,7 @@ nav ul box-sizing: initial padding: 0 15px 15px - .lobbies + .rooms min-width: 145px .game-list From b5f049a378b7221e067b3f6e0f235fdbcc4171f1 Mon Sep 17 00:00:00 2001 From: Lukasz Dobrogowski Date: Fri, 12 Feb 2016 16:21:10 +0100 Subject: [PATCH 9/9] replaced select with tabs --- src/cljs/netrunner/gamelobby.cljs | 20 ++++++++++++-------- src/css/base.styl | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/cljs/netrunner/gamelobby.cljs b/src/cljs/netrunner/gamelobby.cljs index f7776ef44d..a189d19bb3 100644 --- a/src/cljs/netrunner/gamelobby.cljs +++ b/src/cljs/netrunner/gamelobby.cljs @@ -213,14 +213,18 @@ [:div.games [:div.button-bar (if gameid - [:button {:class "disabled"} "New game"] - [:button {:on-click #(new-game cursor owner)} "New game"]) - [:div.float-right "Room: " - (let [count-games (fn [room] (count (filter #(= room (:room %)) games)))] - [:select.rooms {:value (om/get-state owner :current-room) - :on-change #(om/set-state! owner :current-room (.. % -target -value))} - [:option {:value "casual"} (str "Casual (" (count-games "casual") ")")] - [:option {:value "competitive"} (str "Competitive (" (count-games "competitive") ")")]])]] + [:button.float-left {:class "disabled"} "New game"] + [:button.float-left {:on-click #(new-game cursor owner)} "New game"]) + (let [count-games (fn [room] (count (filter #(= room (:room %)) games))) + room-tab (fn [room roomname] + [:span.roomtab + (if (= room (om/get-state owner :current-room)) + {:class "current"} + {:on-click #(om/set-state! owner :current-room room)}) + roomname " (" (count-games room) ")"])] + [:div.rooms + (room-tab "competitive" "Competitive") + (room-tab "casual" "Casual")])] (game-list cursor owner)] [:div.game-panel diff --git a/src/css/base.styl b/src/css/base.styl index 05f0242df0..f924aca0f4 100644 --- a/src/css/base.styl +++ b/src/css/base.styl @@ -948,8 +948,23 @@ nav ul box-sizing: initial padding: 0 15px 15px - .rooms - min-width: 145px + .rooms .roomtab + display: block + padding: 5px 10px + border: 1px solid white + border-radius: 4px + color: white + margin-right: 1px + cursor: pointer + float: right + + &:hover + border-color: orange + color: orange + + &.current + border-color: orange + cursor: default .game-list padding: 0 15px