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

Fixes cards being draggable for spectators. #1031

Merged
merged 3 commits into from
Dec 23, 2015
Merged
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
10 changes: 7 additions & 3 deletions src/cljs/netrunner/gameboard.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
(defn send [msg]
(.emit socket "netrunner" (clj->js msg)))

(defn not-spectator? [game-state app-state]
(#{(get-in @game-state [:corp :user]) (get-in @game-state [:runner :user])} (:user @app-state)))

(defn send-command
([command] (send-command command nil))
([command args]
Expand Down Expand Up @@ -109,7 +112,7 @@
(defn handle-card-click [{:keys [type zone counter advance-counter advancementcost advanceable
root] :as card} owner]
(let [side (:side @game-state)]
(when (#{(get-in @game-state [:corp :user]) (get-in @game-state [:runner :user])} (:user @app-state))
(when (not-spectator? game-state app-state)
(if (= (get-in @game-state [side :prompt 0 :prompt-type]) "select")
(send-command "select" {:card card})
(if (and (= (:type card) "Identity") (= side (keyword (.toLowerCase (:side card)))))
Expand Down Expand Up @@ -276,7 +279,8 @@
(when code
(sab/html
[:div.card-frame
[:div.blue-shade.card {:class (when selected "selected") :draggable true
[:div.blue-shade.card {:class (when selected "selected")
:draggable (when (not-spectator? game-state app-state) true)
:on-drag-start #(handle-dragstart % cursor)
:on-drag-end #(-> % .-target js/$ (.removeClass "dragged"))
:on-mouse-enter #(when (or (not (or flipped facedown))
Expand Down Expand Up @@ -653,7 +657,7 @@
[:div
(om/build rfg-view {:cards (:rfg opponent) :name "Removed from the game"})
(om/build rfg-view {:cards (:rfg me) :name "Removed from the game"})
(om/build rfg-view {:cards (:play-area me)})
(when (not-spectator? game-state app-state) (om/build rfg-view {:cards (:play-area me)}))
(om/build rfg-view {:cards (:current opponent) :name "Current"})
(om/build rfg-view {:cards (:current me) :name "Current"})]
(when-not (= side :spectator)
Expand Down