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

Redo on user-selected skill levels for games #755

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/cljs/netrunner/gamelobby.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
(defn new-game [cursor owner]
(authenticated
(fn [user]
(om/set-state! owner :title (str (:username user) "'s game"))
(om/set-state! owner :title "Friendly game")
(om/set-state! owner :skill-level "Intermediate")
(om/set-state! owner :game-type "Friendly")
(om/set-state! owner :editing true)
(om/set-state! owner :allowspectator true)
(-> ".game-title" js/$ .select))))
Expand All @@ -64,6 +66,12 @@
(send {:action "create" :title (om/get-state owner :title)
:allowspectator (om/get-state owner :allowspectator)}))))))

(defn auto-game-title [skill game-type]
(cond
(= game-type "Private") "Private game"
(= skill "Intermediate") (str game-type " game")
:else (str game-type " game for " (clojure.string/lower-case skill) "s")))

(defn join-game [gameid owner]
(authenticated
(fn [user]
Expand Down Expand Up @@ -195,6 +203,20 @@
[:div.button-bar
[:button {:type "button" :on-click #(create-game cursor owner)} "Create"]
[:button {:type "button" :on-click #(om/set-state! owner :editing false)} "Cancel"]]
[:h4 "Game Type"]
[:select.game-type {:value (:game-type state)
:on-change #(do (om/set-state! owner :game-type (.. % -target -value))
(om/set-state! owner :title (auto-game-title (:skill-level state)
(.. % -target -value))))}
(for [option ["Private" "Friendly" "Serious" "Tournament"]]
[:option {:value option :dangerouslySetInnerHTML #js {:__html option}}])]
[:h4 "Skill Level"]
[:select.game-skill {:value (:skill-level state)
:on-change #(do (om/set-state! owner :skill-level (.. % -target -value))
(om/set-state! owner :title (auto-game-title (.. % -target -value)
(:game-type state))))}
(for [option ["Beginner" "Intermediate" "Expert"]]
[:option {:value option :dangerouslySetInnerHTML #js {:__html option}}])]
[:h4 "Title"]
[:input.game-title {:on-change #(om/set-state! owner :title (.. % -target -value))
:value (:title state) :placeholder "Title"}]
Expand Down
6 changes: 6 additions & 0 deletions src/css/base.styl
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,12 @@ nav ul
.game-title
width: 250px

.game-skill
width: 150px

.game-type
width: 150px

.deck-collection
width: 496px
max-height: 355px
Expand Down