From: Benjamin Auder Date: Sat, 11 Apr 2020 18:50:04 +0000 (+0200) Subject: Freeze time between receiving a move and end of animation: more fair (especially... X-Git-Url: https://git.auder.net/doc/html/css/img/current/git-favicon.png?a=commitdiff_plain;h=5e38a642ffa0ef5f0076aa0df05aa935b027f649;p=vchess.git Freeze time between receiving a move and end of animation: more fair (especially for Sittuyin) --- diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 8f40deac..878e7718 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -807,10 +807,25 @@ export default { } } this.$refs["basegame"].play(movePlus.move, "received"); - this.game.clocks[moveColIdx] = movePlus.clock; - this.processMove( - movePlus.move, - { receiveMyMove: receiveMyMove } + // Freeze time while the move is being play + // (TODO: a callback would be cleaner here) + clearInterval(this.clockUpdate); + this.clockUpdate = null; + const freezeDuration = ["all", "highlight"].includes(V.ShowMoves) + // 250 = length of animation, 500 = delay between sub-moves + ? 250 + 750 * + (Array.isArray(movePlus.move) ? movePlus.move.length - 1 : 0) + // Incomplete information: no move animation + : 0; + setTimeout( + () => { + this.game.clocks[moveColIdx] = movePlus.clock; + this.processMove( + movePlus.move, + { receiveMyMove: receiveMyMove } + ); + }, + freezeDuration ); } }