+ let clockUpdate = setInterval(() => {
+
+
+
+
+console.log(countdown);
+ console.log(this.vr.turn +" " + currentTurn + " " + this.vr.getFen());
+
+// TODO: incoherent state because vr is altered in BaseGame to replay game
+ // ==> should use a temporary vr ?
+
+
+
+ if (countdown <= 0 || this.vr.turn != currentTurn)
+ {
+ clearInterval(clockUpdate);
+ if (countdown <= 0 && myTurn)
+ {
+ this.$refs["basegame"].endGame(
+ this.game.mycolor=="w" ? "0-1" : "1-0", "Time");
+ this.game.players.forEach(p => {
+ if (p.sid != this.st.user.sid)
+ {
+ this.st.conn.send(JSON.stringify({
+ code: "timeover",
+ target: p.sid,
+ }));
+ }
+ });
+ }
+ }
+ // TODO: with Vue 3, just do this.virtualClocks[colorIdx] = ppt(--countdown)
+ this.$set(this.virtualClocks, colorIdx, ppt(Math.max(0, --countdown)));
+ }, 1000);