* score: varchar (result)
* scoreMsg: varchar ("Time", "Mutual agreement"...)
* created: datetime
- * drawOffer: boolean
+ * drawOffer: char ('w','b' or '' for none)
*
* Structure table Players:
* gid: ref game id
"INSERT INTO Games"
+ " (vid, fenStart, fen, score, timeControl, created, drawOffer)"
+ " VALUES (" + vid + ",'" + fen + "','" + fen + "','*','"
- + timeControl + "'," + Date.now() + "," + false + ")";
+ + timeControl + "'," + Date.now() + ",'')";
db.run(query, function(err) {
if (!!err)
return cb(err);
let modifs = "";
if (!!obj.message)
modifs += "message = message || ' ' || '" + obj.message + "',";
- if ([true,false].includes(obj.drawOffer))
+ // NOTE: if drawOffer is true, we should check that it's player's turn
+ // A bit overcomplicated. Let's trust the client on that for now...
+ if (!!obj.drawOffer)
modifs += "drawOffer = " + obj.drawOffer + ",";
if (!!obj.fen)
modifs += "fen = '" + obj.fen + "',";