Fix clocks in corr games
authorBenjamin Auder <benjamin.auder@somewhere>
Tue, 3 Mar 2020 22:31:55 +0000 (23:31 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Tue, 3 Mar 2020 22:31:55 +0000 (23:31 +0100)
client/src/variants/Dark.js
client/src/views/Game.vue

index 81f8700..96163bf 100644 (file)
@@ -78,6 +78,11 @@ export const VariantRules = class DarkRules extends ChessRules {
     }
   }
 
+  filterValid(moves) {
+    // Used in the interface
+    return moves;
+  }
+
   // Has to be redefined to avoid an infinite loop
   getAllValidMoves() {
     const color = this.turn;
index 6c289e6..5471a3f 100644 (file)
@@ -517,8 +517,10 @@ export default {
             if (L >= 1) {
               const gameLastupdate = game.moves[L-1].played;
               game.initime[L % 2] = gameLastupdate;
-              if (L >= 2)
-                game.clocks[L % 2] = Date.now() - gameLastupdate;
+              if (L >= 2) {
+                game.clocks[L % 2] =
+                  tc.mainTime - (Date.now() - gameLastupdate) / 1000;
+              }
             }
           }
           // Sort chat messages from newest to oldest