g.cadence.match(/^[0-9dhms +]+$/) &&
g.fen.match(/^[a-zA-Z0-9, /-]*$/) &&
g.players.length == 2 &&
- g.players.every(p => p.id.toString().match(/^[0-9]+$/))
+ g.players.every(p => p.uid.toString().match(/^[0-9]+$/))
);
},
const color = (idx==0 ? "w" : "b");
query =
"INSERT INTO Players VALUES " +
- "(" + this.lastID + "," + p.id + ",'" + color + "')";
+ "(" + this.lastID + "," + p.uid + ",'" + color + "')";
db.run(query);
});
cb(null, {gid: this.lastID});
"FROM Chats " +
"WHERE gid = " + id;
db.all(query, (err4, chats) => {
- const game = Object.assign({},
+ const game = Object.assign(
+ {},
gameInfo,
{
players: players,
"FROM Moves " +
"WHERE gid = " + id;
db.get(query, (err,ret) => {
- const game = Object.assign({},
+ const game = Object.assign(
+ {},
gameInfo,
{
players: players,
)
) && (
!obj.drawOffer || !!(obj.drawOffer.match(/^[wbtn]$/))
+ ) && (
+ !obj.rematchOffer || !!(obj.rematchOffer.match(/^[wbn]$/))
) && (
!obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9, /-]*$/))
) && (
let modifs = "";
// NOTE: if drawOffer is set, we should check that it's player's turn
// A bit overcomplicated. Let's trust the client on that for now...
- if (obj.drawOffer)
+ if (!!obj.drawOffer)
{
- if (obj.drawOffer == "n") //Special "None" update
+ if (obj.drawOffer == "n") //special "None" update
obj.drawOffer = "";
modifs += "drawOffer = '" + obj.drawOffer + "',";
}
+ if (!!obj.rematchOffer)
+ {
+ if (obj.rematchOffer == "n") //special "None" update
+ obj.rematchOffer = "";
+ modifs += "rematchOffer = '" + obj.rematchOffer + "',";
+ }
if (!!obj.fen)
modifs += "fen = '" + obj.fen + "',";
if (!!obj.score)