Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split game lobby into casual/competitive rooms #1215

Merged
merged 9 commits into from
Feb 14, 2016
2 changes: 1 addition & 1 deletion server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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, room: msg.room,\
players: [{user: socket.request.user, id: socket.id, side: msg.side}], spectators: []}
games[gameid] = game
socket.join(gameid)
Expand Down
2 changes: 1 addition & 1 deletion src/cljs/netrunner/deckbuilder.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 38 additions & 20 deletions src/cljs/netrunner/gamelobby.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
:room (om/get-state owner :current-room)}))))))

(defn join-game [gameid owner]
(authenticated
Expand Down Expand Up @@ -180,34 +181,51 @@
[:input {:ref "msg-input" :placeholder "Say something" :accessKey "l"}]
[:button "Send"]]]]))))

(defn game-list [{:keys [games gameid] :as cursor} owner]
(let [roomgames (filter #(= (:room %) (om/get-state owner :current-room)) games)]
[:div.game-list
(if (empty? roomgames)
[:h4 "No games"]
(for [game roomgames]
[: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-room "casual"})

om/IRenderState
(render-state [this state]
(sab/html
[:div.lobby.panel.blue-shade
[:div.games
[:div.button-bar
(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))]]))]]
[: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
(if (:editing state)
Expand Down
8 changes: 4 additions & 4 deletions src/cljs/netrunner/help.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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 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?"
:content [:p "Sadly, this window is currently unimplemented - you need to ask the Runner manually. "
Expand Down
18 changes: 18 additions & 0 deletions src/css/base.styl
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,24 @@ nav ul
box-sizing: initial
padding: 0 15px 15px

.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
overflow: auto
Expand Down