chiark / gitweb /
clock: Give Y an extra per_move
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 21:28:43 +0000 (21:28 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 21:55:05 +0000 (21:55 +0000)
This breaks detection of whether we're reset.  We'll fix that in a
moment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/clock.rs

index 675c0a93b448c39e44fcc798b517168dd8bbf5e7..27a8690eac65281a474957257d30d70cd91e90ba 100644 (file)
@@ -115,6 +115,11 @@ impl State {
     for ust in &mut self.users {
       ust.remaining = spec.initial_time();
     }
+    // White is player Y, and they will ge to go first, so the clock
+    // will go from stopped to Y, and then later when it's X's turn
+    // X will get an extra per_move.  Y therefore needs per_move too.
+    let y_remaining = &mut self.users[USERS[0]].remaining;
+    *y_remaining = *y_remaining + TVL::seconds(spec.per_move.into());
   }
 
   fn implies_running(&self, held: Option<PlayerId>) -> Option<User> {