X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fdata%2FchallengeCheck.js;h=c2700008370f5fbb6014782acc09e8f6633f2962;hp=e0aa978cda51ba36f589eb2d53da883fa2cb96b6;hb=bebcc8d45532e67902175f69084a08040f06855f;hpb=6e3a7e26d57f60480b08abed7441963674a79b18 diff --git a/client/src/data/challengeCheck.js b/client/src/data/challengeCheck.js index e0aa978c..c2700008 100644 --- a/client/src/data/challengeCheck.js +++ b/client/src/data/challengeCheck.js @@ -9,27 +9,17 @@ export function checkChallenge(c) const tc = extractTime(c.timeControl); if (!tc) return "Wrong time control"; - // Less than 3 days ==> live game (TODO: heuristic... 40 moves also) - c.liveGame = (tc.mainTime + 40 * tc.increment < 3*24*60*60); - // Basic alphanumeric check for players names - let playerCount = 0; - for (const pname of c.to) + // Basic alphanumeric check for opponent name + if (!!c.to) { - if (pname.length > 0) - { - // TODO: slightly redundant (see data/userCheck.js) - if (!pname.match(/^[\w]+$/)) - return "Wrong characters in players names"; - playerCount++; - } + // TODO: slightly redundant (see data/userCheck.js) + if (!c.to.match(/^[\w]+$/)) + return "Wrong characters in opponent name"; } - if (playerCount > 0 && playerCount != c.nbPlayers-1) - return "None, or all of the opponent names must be filled" - // Allow custom FEN (and check it) only for individual challenges - if (c.fen.length > 0 && playerCount > 0) + if (c.fen.length > 0 && !!c.to) { if (!V.IsGoodFen(c.fen)) return "Bad FEN string";