X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fmodels%2FGame.js;h=39459176acfbe534c002dbca46e69a1de184c262;hp=e970bfbe39a115c0e49f7f81b4650ccdb43206b5;hb=188b4a8f2e3edfa86c4e9169ddac9a14ebc12689;hpb=4b24c8ac99330258005c9e7c362f1f1720b97d9a diff --git a/server/models/Game.js b/server/models/Game.js index e970bfbe..39459176 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -197,17 +197,17 @@ const GameModel = return ( ( !obj.move || ( - obj.move.played.toString().match(/^[0-9]+$/) && - obj.move.idx.toString().match(/^[0-9]+$/) + !!(obj.move.played.toString().match(/^[0-9]+$/)) && + !!(obj.move.idx.toString().match(/^[0-9]+$/)) ) ) && ( - !obj.drawOffer || obj.drawOffer.match(/^[wbtn]$/) + !obj.drawOffer || !!(obj.drawOffer.match(/^[wbtn]$/)) ) && ( - !obj.fen || obj.fen.match(/^[a-zA-Z0-9, /-]*$/) + !obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9, /-]*$/)) ) && ( - !obj.score || obj.score.match(/^[012?*\/-]+$/) + !obj.score || !!(obj.score.match(/^[012?*\/-]+$/)) ) && ( - !obj.scoreMsg || obj.scoreMsg.match(/^[a-zA-Z ]+$/) + !obj.scoreMsg || !!(obj.scoreMsg.match(/^[a-zA-Z ]+$/)) ) && ( !obj.chat || UserModel.checkNameEmail({name: obj.chat.name}) ) @@ -242,11 +242,6 @@ const GameModel = query += modifs + " WHERE id = " + id; db.run(query); } - - -return cb({errmsg: JSON.stringify(obj.move) + " " + (!!obj.move)}); - - // NOTE: move, chat and delchat are mutually exclusive if (!!obj.move) { @@ -257,10 +252,6 @@ return cb({errmsg: JSON.stringify(obj.move) + " " + (!!obj.move)}); "WHERE gid = " + id; db.get(query, (err,ret) => { const m = obj.move; - -//return cb({errmsg: ret.maxIdx + " " + m.idx + " " + (!ret.maxIdx || ret.maxIdx + 1 == m.idx) + " " + query}); - - if (!ret.maxIdx || ret.maxIdx + 1 == m.idx) { query = "INSERT INTO Moves (gid, squares, played, idx) VALUES " +