- this.st.conn.send(JSON.stringify({
- code: "lastate",
- target: data.from,
- state:
- {
- // NOTE: lastMove (when defined) includes addTime
- lastMove: (L>0 ? this.game.moves[L-1] : undefined),
- // Since we played a move (or abort or resign),
- // only drawOffer=="sent" is possible
- drawSent: this.drawOffer == "sent",
- score: this.game.score,
- movesCount: L,
- initime: this.game.initime[1-myIdx], //relevant only if I played
- }
- }));
- }
- break;
- case "askgame":
- // Send current (live) game if I play in (not an observer),
- // and not asked by opponent (!)
- if (this.game.type == "live"
- && this.game.players.some(p => p.sid == this.st.user.sid)
- && this.game.players.every(p => p.sid != data.from))
- {
- const myGame =
- {
- // Minimal game informations:
- id: this.game.id,
- players: this.game.players,
- vid: this.game.vid,
- timeControl: this.game.timeControl,
+ const myLastate = {
+ // NOTE: lastMove (when defined) includes addTime
+ lastMove: (L>0 ? this.game.moves[L-1] : undefined),
+ // Since we played a move (or abort or resign),
+ // only drawOffer=="sent" is possible
+ drawSent: this.drawOffer == "sent",