let notation = super.getNotation(move);
// Add a capture mark (not describing what is captured...):
if (move.vanish.length > 1 && move.appear.length == 1) {
- if (notation.match(/^[a-h]x/))
+ if (!!(notation.match(/^[a-h]x/)))
// Pawn capture: remove initial "b" in bxc4 for example
notation = notation.substr(1);
notation = notation.replace("x","") + "X";
let notation = super.getNotation(move);
// Add a capture mark (not describing what is captured...):
if (move.vanish.length > 1 && move.appear.length == 1) {
- if (notation.match(/^[a-h]x/))
+ if (!!(notation.match(/^[a-h]x/)))
// Pawn capture: remove initial "b" in bxc4 for example
notation = notation.substr(1);
notation = notation.replace("x","") + "X";
break;
}
if (this.game.type == "corr") {
+
+
+console.log("new fen : " + this.game.fen);
+
GameStorage.update(this.gameRef.id, {
fen: this.game.fen,
move: {
}
},
newChallenge: async function() {
- if (this.newchallenge.cadence.match(/^[0-9]+$/))
+ if (!!(this.newchallenge.cadence.match(/^[0-9]+$/)))
this.newchallenge.cadence += "+0"; //assume minutes, no increment
const ctype = this.classifyObject(this.newchallenge);
// TODO: cadence still unchecked so ctype could be wrong...
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})
)
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)
{
"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 " +
checkNameEmail: function(o)
{
return (
- (!o.name || o.name.match(/^[\w-]+$/)) &&
- (!o.email || o.email.match(/^[\w.+-]+@[\w.+-]+$/))
+ (!o.name || !!(o.name.match(/^[\w-]+$/))) &&
+ (!o.email || !!(o.email.match(/^[\w.+-]+@[\w.+-]+$/)))
);
},