From: Benjamin Auder Date: Fri, 8 Feb 2019 15:47:24 +0000 (+0100) Subject: Simplify 'to' in newchallenge on hall view X-Git-Url: https://git.auder.net/doc/html/vendor/scripts/getGraph_%22%20%20%20this.image%20%20%20%22.php?a=commitdiff_plain;h=6faa92f2f81bc0ac6a937222cb8ef3a64ac6acd8;p=vchess.git Simplify 'to' in newchallenge on hall view --- 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;