From 5e38a642ffa0ef5f0076aa0df05aa935b027f649 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Sat, 11 Apr 2020 20:50:04 +0200 Subject: [PATCH] Freeze time between receiving a move and end of animation: more fair (especially for Sittuyin) --- client/src/views/Game.vue | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) 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 ); } } -- 2.44.0