chiark / gitweb /
wdt: Use w.piece_held()
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 29 Jan 2021 18:21:37 +0000 (18:21 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 29 Jan 2021 23:56:12 +0000 (23:56 +0000)
Rather than the clone-and-hack copy.  Tidying up, NFC.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
wdriver/wdt-simple.rs

index e71423f60069edcee3542e2f618906c499959286..834a369ff4585eac55c891bd2a70ebe058eeb19e 100644 (file)
@@ -235,7 +235,7 @@ impl Ctx {
     struct Got {
       now: Pos,
       log: Vec<String>,
-      held: serde_json::Value,
+      held: Option<String>,
     }
 
     let gots = sides.iter().map(|side|{
@@ -255,11 +255,7 @@ impl Ctx {
         .collect::<Result<Vec<String>,_>>()?;
 
       // xxx clone and hack
-      let held = w.execute_script(&format!(r##"
-        let pc = pieces['{}'];
-        return pc.held;
-                       "##, &pc))?;
-      let held = held.value().to_owned();
+      let held = w.piece_held(&pc)?;
 
       Ok::<_,AE>(Got { now, log, held })
     }).collect::<Result<Vec<_>,AE>>()?;