X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=f00dc92b298efc8ab91e3c958daf7a3260e28b38;hp=2fdd2238290740950817002ca906520804aaaeef;hb=dce792f64ab0a311d348a6eb05c440dd1b170bd3;hpb=db13014d0aee87402afc2289131d65c401f71bfe diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 2fdd2238..f00dc92b 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -79,6 +79,12 @@ export default { } }, "game.clocks": function(newState) { + if (this.game.moves.length < 2) + { + // 1st move not completed yet: freeze time + this.virtualClocks = newState.map(s => ppt(s)); + return; + } const currentTurn = this.vr.turn; const colorIdx = ["w","b"].indexOf(currentTurn); let countdown = newState[colorIdx] - @@ -380,12 +386,15 @@ export default { return obj; }, {}); // Send move ("newmove" event) to opponent(s) (if ours) - let addTime = undefined; + let addTime = 0; if (move.color == this.game.mycolor) { - const elapsed = Date.now() - this.game.initime[colorIdx]; - // elapsed time is measured in milliseconds - addTime = this.game.increment - elapsed/1000; + if (this.game.moves.length >= 2) //after first move + { + const elapsed = Date.now() - this.game.initime[colorIdx]; + // elapsed time is measured in milliseconds + addTime = this.game.increment - elapsed/1000; + } this.st.conn.send(JSON.stringify({ code: "newmove", target: this.game.oppid,