From 29ced362f46ae68e4314985bf836b3adeba23f32 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Sun, 9 Feb 2020 02:07:30 +0100 Subject: [PATCH] Fixes --- client/src/translations/en.js | 1 + client/src/translations/es.js | 1 + client/src/translations/fr.js | 1 + client/src/views/Game.vue | 9 ++++++--- client/src/views/Hall.vue | 21 +++++++++++---------- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/client/src/translations/en.js b/client/src/translations/en.js index bb5f39fa..ae1101df 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -60,6 +60,7 @@ export const translations = "Play with?": "Play with?", "Playing": "Playing", "Please log in to accept corr challenges": "Please log in to accept corr challenges", + "Please log in to play correspondance games": "Please log in to play correspondance games", "Please select a variant": "Please select a variant", "Practice": "Practice", "Processing... Please wait": "Processing... Please wait", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index 0b1830d3..0e9724b8 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -60,6 +60,7 @@ export const translations = "Play with?": "¿ Jugar con ?", "Playing": "Jugando", "Please log in to accept corr challenges": "Inicia sesión para aceptar los desafíos por correspondencia", + "Please log in to play correspondance games": "Inicia sesión para jugar partidas por correspondancia", "Please select a variant": "Por favor seleccione una variante", "Practice": "Práctica", "Processing... Please wait": "Procesando... por favor espere", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index 54e316c1..15673519 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -60,6 +60,7 @@ export const translations = "Play with?": "Jouer avec ?", "Playing": "Jouant", "Please log in to accept corr challenges": "Identifiez vous pour accepter des défis par correspondance", + "Please log in to play correspondance games": "Identifiez vous pour jouer des parties par correspondance", "Please select a variant": "Sélectionnez une variante SVP", "Practice": "Pratiquer", "Processing... Please wait": "Traitement en cours... Attendez SVP", diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index baa9ae19..0072bd43 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -152,10 +152,13 @@ export default { this.st.conn.send(JSON.stringify({code:"pollclients"})); }, isConnected: function(index) { - const name = this.game.players[index].name; - if (this.st.user.name == name) + const player = this.game.players[index]; + // Is it me ? + if (this.st.user.sid == player.sid || this.st.user.id == player.uid) return true; - return Object.values(this.people).some(p => p.name == name); + // Try to find a match in people: + return Object.keys(this.people).some(sid => sid == player.sid) || + Object.values(this.people).some(p => p.id == player.uid); }, socketMessageListener: function(msg) { const data = JSON.parse(msg.data); diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index fbd5e286..bbff9b95 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -509,17 +509,18 @@ export default { this.newchallenge.to = this.people[sid].name; doClick("modalNewgame"); }, - challOrWatch: function(sid, e) { - switch (e.target.innerHTML) + challOrWatch: function(sid) { + if (!this.people[sid].gamer) { - case "Available": - this.tryChallenge(sid); - break; - case "Playing": - this.showGame(this.games.find( - g => g.players.some(pl => pl.sid == sid || pl.uid == this.people[sid].id))); - break; - }; + // Available, in Hall + this.tryChallenge(sid); + } + else + { + // Playing, in Game + this.showGame(this.games.find( + g => g.players.some(pl => pl.sid == sid || pl.uid == this.people[sid].id))); + } }, newChallenge: async function() { if (this.newchallenge.vid == "") -- 2.44.0