From ef42239d2c7f3264e929eae5d1f9ee4a67dd564b Mon Sep 17 00:00:00 2001 From: Steffen Date: Sun, 19 Jul 2020 20:40:40 +0200 Subject: [PATCH 1/3] added another domain to server whitelist --- server/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/index.js b/server/index.js index 7c9cd4a..130b894 100644 --- a/server/index.js +++ b/server/index.js @@ -9,7 +9,9 @@ const server = https.createServer({ const wss = new WebSocket.Server({ ...(process.env.NODE_ENV === "development" ? { port: 8081 } : { server }), verifyClient: info => - !!info.origin.match(/^https?:\/\/(bra1n\.github\.io|localhost)/i) + !!info.origin.match( + /^https?:\/\/(bra1n\.github\.io|localhost|eddbra1nprivatetownsquare\.xyz)/i + ) }); function noop() {} From e19aa7a6feb00c223e084ff8c6d35874fb833b48 Mon Sep 17 00:00:00 2001 From: Steffen Date: Sun, 19 Jul 2020 21:11:23 +0200 Subject: [PATCH 2/3] fix swapping and moving players in live sessions (fixes #46) --- package-lock.json | 8 ++++---- package.json | 2 +- src/components/Token.vue | 2 ++ src/store/modules/players.js | 2 ++ src/store/socket.js | 34 +++++++++++++++++++++++++++++++++- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8feb838..bfcb56d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "townsquare", - "version": "1.3.0", + "version": "1.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -5015,9 +5015,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" }, "lodash.defaultsdeep": { "version": "4.6.1", diff --git a/package.json b/package.json index 2351a32..7e9faae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "townsquare", - "version": "1.4.0", + "version": "1.4.2", "description": "Blood on the Clocktower Town Square", "author": "Steffen Baumgart", "scripts": { diff --git a/src/components/Token.vue b/src/components/Token.vue index 7d19cc0..9315694 100644 --- a/src/components/Token.vue +++ b/src/components/Token.vue @@ -82,6 +82,8 @@ export default { .icon { background-size: 100%; + background-repeat: no-repeat; + background-position: center 30%; position: absolute; width: 100%; height: 100%; diff --git a/src/store/modules/players.js b/src/store/modules/players.js index 491b40b..e5b47b0 100644 --- a/src/store/modules/players.js +++ b/src/store/modules/players.js @@ -102,6 +102,8 @@ const mutations = { state.players[to], state.players[from] ]; + // hack: "modify" the array so that Vue notices something changed + state.players.splice(0, 0); }, move(state, [from, to]) { state.players.splice(to, 0, state.players.splice(from, 1)[0]); diff --git a/src/store/socket.js b/src/store/socket.js index 6eaaee2..1d6f62b 100644 --- a/src/store/socket.js +++ b/src/store/socket.js @@ -105,9 +105,19 @@ class LiveSession { this._handlePing(params); break; case "nomination": + if (!this._isSpectator) return; this._store.commit("session/nomination", { nomination: params }); break; + case "swap": + if (!this._isSpectator) return; + this._store.commit("players/swap", params); + break; + case "move": + if (!this._isSpectator) return; + this._store.commit("players/move", params); + break; case "votingSpeed": + if (!this._isSpectator) return; this._store.commit("session/setVotingSpeed", params); break; case "vote": @@ -495,6 +505,24 @@ class LiveSession { } } } + + /** + * Swap two player seats. ST only + * @param payload + */ + swapPlayer(payload) { + if (this._isSpectator) return; + this._send("swap", payload); + } + + /** + * Move a player to another seat. ST only + * @param payload + */ + movePlayer(payload) { + if (this._isSpectator) return; + this._send("move", payload); + } } export default store => { @@ -530,9 +558,13 @@ export default store => { case "setEdition": session.sendEdition(); break; - case "players/set": case "players/swap": + session.swapPlayer(payload); + break; case "players/move": + session.movePlayer(payload); + break; + case "players/set": case "players/clear": case "players/remove": case "players/add": From 1ce9c08dc3610911702cb8ddc6c7cbc491fe54c1 Mon Sep 17 00:00:00 2001 From: Steffen Date: Sun, 19 Jul 2020 21:16:45 +0200 Subject: [PATCH 3/3] keep night order for dead players (closes #47) --- package-lock.json | 2 +- package.json | 2 +- src/components/Player.vue | 3 ++- src/store/modules/players.js | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index bfcb56d..3338312 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "townsquare", - "version": "1.4.2", + "version": "1.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7e9faae..bfe0656 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "townsquare", - "version": "1.4.2", + "version": "1.5.0", "description": "Blood on the Clocktower Town Square", "author": "Steffen Baumgart", "scripts": { diff --git a/src/components/Player.vue b/src/components/Player.vue index aab6a97..892cda7 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -806,7 +806,8 @@ li.move:not(.from) .player .overlay svg.move { } .player.dead .night em { - opacity: 0; + color: #ddd; + background: linear-gradient(180deg, rgba(0, 0, 0, 1) 0%, gray 100%) ; } /***** Reminder token *****/ diff --git a/src/store/modules/players.js b/src/store/modules/players.js index e5b47b0..5ced014 100644 --- a/src/store/modules/players.js +++ b/src/store/modules/players.js @@ -25,8 +25,8 @@ const getters = { nightOrder({ players }) { const firstNight = [0]; const otherNight = [0]; - players.forEach(({ role, isDead }) => { - if (isDead) return; + players.forEach(({ role }) => { + // if (isDead) return; if (role.firstNight && !firstNight.includes(role.firstNight)) { firstNight.push(role.firstNight); }