chiark
/
gitweb
/
~ianmdlvl
/
otter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
798d108
)
clock: Break out State::reset (nfc)
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 16:53:25 +0000
(16:53 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 21:42:32 +0000
(21:42 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/clock.rs
patch
|
blob
|
history
diff --git
a/src/clock.rs
b/src/clock.rs
index c418ca0657be46a1b8df13595a2fad54389d720d..a924e536aecc9a5354433b14804d6bb28b7e979a 100644
(file)
--- a/
src/clock.rs
+++ b/
src/clock.rs
@@
-109,6
+109,12
@@
impl State {
current: None,
}
}
+
+ fn reset(&mut self, spec: &ChessClock) {
+ for ust in &mut self.users {
+ ust.remaining = spec.initial_time();
+ }
+ }
}
#[typetag::serde(name="ChessClock")]
@@
-438,9
+444,7
@@
impl PieceTrait for Clock {
if state.current.is_some() {
throw!(OE::BadPieceStateForOperation);
}
- for ust in &mut state.users {
- ust.remaining = self.spec.initial_time();
- }
+ state.reset(&self.spec);
(Unpredictable, format!("reset"))
},
"claim-x" | "claim-y" => { // xxx these need to be Unpredictable