From 6faa92f2f81bc0ac6a937222cb8ef3a64ac6acd8 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Fri, 8 Feb 2019 16:47:24 +0100 Subject: [PATCH] Simplify 'to' in newchallenge on hall view --- client/src/data/challengeCheck.js | 6 +++--- client/src/views/Hall.vue | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/client/src/data/challengeCheck.js b/client/src/data/challengeCheck.js index c533b11d..17cf296f 100644 --- a/client/src/data/challengeCheck.js +++ b/client/src/data/challengeCheck.js @@ -55,12 +55,12 @@ export function checkChallenge(c) // Basic alphanumeric check for players names let playerCount = 0; - for (const p of c.to) + for (const pname of c.to) { - if (p.name.length > 0) + if (pname.length > 0) { // TODO: slightly redundant (see data/userCheck.js) - if (!p.name.match(/^[\w]+$/)) + if (!pname.match(/^[\w]+$/)) return "Wrong characters in players names"; playerCount++; } diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 145d8987..b94d85b5 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -84,14 +84,8 @@ export default { fen: "", vid: 0, nbPlayers: 0, - // NOTE: id (server DB) and sid (socket ID). - // Anonymous players just have a socket ID. - to: [ - {id:0, sid:"", name:""}, - {id:0, sid:"", name:""}, - {id:0, sid:"", name:""} - ], - timeControl: "", + to: ["", "", ""], //name of challenged players + timeControl: "", //"2m+2s" ...etc }, }; }, @@ -276,6 +270,10 @@ export default { if (p.name != "") { const pIdx = this.players.findIndex(pl => pl.name == p.name); + // TODO: for correspondance play we don't require players to be online + // (==> we don't have IDs, and no sid) + // NOTE: id (server DB) and sid (socket ID). + // Anonymous players just have a socket ID. if (pIdx === -1) return alert(p.name + " is not connected"); p.id = this.players[pIdx].id; -- 2.44.0