diff --git a/src/clj/game/core/state.clj b/src/clj/game/core/state.clj index 215572727d..4caf17210f 100644 --- a/src/clj/game/core/state.clj +++ b/src/clj/game/core/state.clj @@ -41,9 +41,9 @@ winning-user]) (defn new-state - [gameid room log now spectatorhands corp runner] + [gameid room now spectatorhands corp runner] (map->State - {:gameid gameid :log log :active-player :runner :end-turn true + {:gameid gameid :log [] :active-player :runner :end-turn true :room room :rid 0 :turn 0 :eid 0 :sfx [] :sfx-current-id 0 diff --git a/src/clj/game/core/turns.clj b/src/clj/game/core/turns.clj index 0086e8496e..5291820c19 100644 --- a/src/clj/game/core/turns.clj +++ b/src/clj/game/core/turns.clj @@ -42,7 +42,7 @@ (defn- init-game-state "Initialises the game state" - [{:keys [players gameid log spectatorhands room] :as game}] + [{:keys [players gameid spectatorhands room] :as game}] (let [corp (some #(when (corp? %) %) players) runner (some #(when (runner? %) %) players) corp-deck (create-deck (:deck corp) (:user corp)) @@ -61,7 +61,6 @@ (new-state gameid room - log (t/now) spectatorhands (new-corp (:user corp) corp-identity corp-options (zone :deck corp-deck) corp-deck-id corp-quote) @@ -73,7 +72,6 @@ (let [state (init-game-state game) corp-identity (get-in @state [:corp :identity]) runner-identity (get-in @state [:runner :identity])] - (system-say state :corp "[hr]") (init-identity state :corp corp-identity) (init-identity state :runner runner-identity) (let [side :corp] diff --git a/src/clj/web/lobby.clj b/src/clj/web/lobby.clj index d26c8dc52e..3dfbe51681 100644 --- a/src/clj/web/lobby.clj +++ b/src/clj/web/lobby.clj @@ -223,11 +223,10 @@ :room room :format format :players [{:user user - :ws-id client-id + :ws-id client-id :side side :options options}] :spectators [] - :log [] :last-update (t/now)}] (swap! all-games assoc gameid game) (swap! client-gameids assoc client-id gameid) @@ -240,26 +239,22 @@ (when-let [{gameid :gameid} (game-for-client client-id)] (when (player-or-spectator client-id gameid) (remove-user client-id gameid) - (let [message {:user "__system__" - :text (str username " left the game.")}] - (swap! all-games update-in [gameid :log] conj message) - (ws/broadcast-to! (lobby-clients gameid) - :lobby/message - message))))) + (ws/broadcast-to! (lobby-clients gameid) + :lobby/message + {:user "__system__" + :text (str username " left the game.")})))) (defn handle-lobby-say [{{{:keys [username] :as user} :user} :ring-req client-id :client-id {:keys [msg gameid]} :?data}] (when (player-or-spectator client-id gameid) - (let [game (game-for-id gameid) - message {:user user - :text msg}] - (swap! all-games update-in [gameid :log] conj message) + (let [game (game-for-id gameid)] (ws/broadcast-to! (map :ws-id (concat (:players game) (:spectators game))) :lobby/message - message)))) + {:user user + :text msg})))) (defn handle-swap-sides [{{{:keys [username] :as user} :user} :ring-req @@ -291,16 +286,14 @@ (if (and (not (already-in-game? user game)) (or (empty? game-password) (bcrypt/check password game-password))) - (let [message {:user "__system__" - :notification "ting" - :text (str username " joined the game.")}] - (join-game user client-id gameid) - (swap! all-games update-in [gameid :log] conj message) - (ws/broadcast-to! (lobby-clients gameid) - :lobby/message - message) - (ws/send! client-id [:lobby/select {:gameid gameid}]) - (when reply-fn (reply-fn 200))) + (do (join-game user client-id gameid) + (ws/broadcast-to! (lobby-clients gameid) + :lobby/message + {:user "__system__" + :notification "ting" + :text (str username " joined the game.")}) + (ws/send! client-id [:lobby/select {:gameid gameid}]) + (when reply-fn (reply-fn 200))) (when reply-fn (reply-fn 403)))) (when reply-fn (reply-fn 404)))) @@ -318,17 +311,16 @@ (if (and (not (already-in-game? user game)) (or (empty? game-password) (bcrypt/check password game-password))) - (let [message {:user "__system__" - :notification "ting" - :text (str username " joined the game as a spectator.")}] - (spectate-game user client-id gameid) - (swap! all-games update-in [gameid :log] conj message) - (ws/broadcast-to! (lobby-clients gameid) - :lobby/message - message) - (ws/send! client-id [:lobby/select {:gameid gameid :started started}]) - (when reply-fn (reply-fn 200)) - true) + (do (spectate-game user client-id gameid) + + (ws/broadcast-to! (lobby-clients gameid) + :lobby/message + {:user "__system__" + :notification "ting" + :text (str username " joined the game as a spectator.")}) + (ws/send! client-id [:lobby/select {:gameid gameid :started started}]) + (when reply-fn (reply-fn 200)) + true) (when reply-fn (reply-fn 403) false)))) diff --git a/test/clj/game_test/core.clj b/test/clj/game_test/core.clj index 26431aeab8..aed45210eb 100644 --- a/test/clj/game_test/core.clj +++ b/test/clj/game_test/core.clj @@ -117,7 +117,6 @@ [{:keys [corp runner mulligan start-as dont-start-turn dont-start-game] :as players}] (let [state (core/init-game {:gameid 1 - :log [] :players [{:side "Corp" :user {:username "Corp"} :deck {:identity (:identity corp)