From: Ian Jackson Date: Sat, 20 Mar 2021 21:23:24 +0000 (+0000) Subject: clock: Actually get per_move basically working X-Git-Tag: otter-0.5.0~615 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a8faaba826d224769793ff677f2debba77b8da15;p=otter.git clock: Actually get per_move basically working There are still some wrinkles. Signed-off-by: Ian Jackson --- diff --git a/src/clock.rs b/src/clock.rs index b22b5e13..675c0a93 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -243,6 +243,17 @@ impl State { spec: &ChessClock, ig: &InstanceRef) { let state = self; + + if_chain! { + if let Some(was_current) = was_current; + if let Some(now_current) = state.current; + if now_current != was_current; + then { + let remaining = &mut state.users[now_current.user].remaining; + *remaining = *remaining + TVL::seconds(spec.per_move.into()); + } + } + if state.implies_running(held) == was_implied_running { return } let now = now()?; @@ -255,16 +266,6 @@ impl State { } } - if_chain! { - if let Some(was_current) = was_current; - if let Some(now_current) = state.current; - if now_current != was_current; - then { - let remaining = &mut state.users[now_current.user].remaining; - *remaining = *remaining + TVL::seconds(spec.per_move.into()); - } - } - if_chain! { if let Some(now_running_user) = state.implies_running(held); then {