From: Benjamin Auder <benjamin.auder@somewhere> Date: Fri, 7 Feb 2020 10:24:29 +0000 (+0100) Subject: Fix passing games X-Git-Url: https://git.auder.net/doc/html/css/scripts/pieces/assets/rpsls.css?a=commitdiff_plain;h=26f3a8879fb4b410ed8840c5a37397011c13bc1c;p=vchess.git Fix passing games --- diff --git a/client/src/components/ChallengeList.vue b/client/src/components/ChallengeList.vue index 095c0966..fd2a9015 100644 --- a/client/src/components/ChallengeList.vue +++ b/client/src/components/ChallengeList.vue @@ -10,7 +10,7 @@ div tbody tr(v-for="c in sortedChallenges" @click="$emit('click-challenge',c)") td(data-label="Variant") {{ c.vname }} - td(data-label="From") {{ c.from.name }} + td(data-label="From") {{ c.from.name || "@nonymous" }} td(data-label="To") {{ c.to }} td(data-label="Cadence") {{ c.timeControl }} </template> diff --git a/client/src/components/GameList.vue b/client/src/components/GameList.vue index d0ea2f01..62c916fa 100644 --- a/client/src/components/GameList.vue +++ b/client/src/components/GameList.vue @@ -7,7 +7,7 @@ div th {{ st.tr["White"] }} th {{ st.tr["Black"] }} th {{ st.tr["Time control"] }} - th(v-if="showResult") Result + th {{ st.tr["Result"] }} tbody tr(v-for="g in sortedGames" @click="$emit('show-game',g)" :class="{'my-turn': g.myTurn}") @@ -15,7 +15,7 @@ div td(data-label="White") {{ g.players[0].name || "@nonymous" }} td(data-label="Black") {{ g.players[1].name || "@nonymous" }} td(data-label="Time control") {{ g.timeControl }} - td(v-if="showResult" data-label="Result") {{ g.score }} + td(data-label="Result") {{ g.score }} </template> <script> @@ -27,13 +27,11 @@ export default { data: function() { return { st: store.state, - showResult: false, }; }, computed: { sortedGames: function() { // Show in order: games where it's my turn, my running games, my games, other games - this.showResult = this.games.some(g => g.score != "*"); let augmentedGames = this.games.map(g => { let priority = 0; if (g.players.some(p => p.uid == this.st.user.id || p.sid == this.st.user.sid)) diff --git a/client/src/translations/en.js b/client/src/translations/en.js index b84230a7..8fa45470 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -67,6 +67,7 @@ export const translations = "Registration complete! Please check your emails": "Registration complete! Please check your emails", "Resign": "Resign", "Resign the game?": "Resign the game?", + "Result": "Result", "Rules": "Rules", "Sample game": "Sample game", "Send": "Send", diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 35cec3a8..608ac717 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -246,6 +246,7 @@ export default { players: this.game.players, vid: this.game.vid, timeControl: this.game.timeControl, + score: this.game.score, }; this.st.conn.send(JSON.stringify({code:"game", game:myGame, target:data.from})); diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 38ec2b30..39d7c167 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -405,7 +405,6 @@ export default { newGame.type = this.classifyObject(data.game); newGame.vname = this.getVname(data.game.vid); newGame.rid = data.from; - newGame.score = "*"; this.games.push(newGame); } break; @@ -455,7 +454,7 @@ export default { this.st.conn.send(JSON.stringify({code:"askgame", target:data.from})); break; case "disconnect": - case "pdisconnect": + case "gdisconnect": this.$delete(this.people, data.from); if (data.code == "disconnect") { diff --git a/server/sockets.js b/server/sockets.js index fcaab83c..e7bb556c 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -123,6 +123,10 @@ module.exports = function(wss) { }); break; } + case "askgame": + clients[obj.target].sock.send(JSON.stringify( + {code:"askgame", from:sid})); + break; case "askfullgame": clients[obj.target].sock.send(JSON.stringify( {code:"askfullgame", from:sid})); @@ -167,7 +171,7 @@ module.exports = function(wss) { notifyRoom(clients[sid].page, "newchat", {chat:obj.chat}); break; // TODO: WebRTC instead in this case (most demanding?) - // --> At least do a "notifyRoom" + // --> Or else: at least do a "notifyRoom" (also for draw, resign...) case "newmove": clients[obj.target].sock.send(JSON.stringify( {code:"newmove", move:obj.move}));