chiark / gitweb /
at-otter hidden: Introduce api_piece_move_synch
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Mar 2021 20:39:43 +0000 (20:39 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Mar 2021 20:39:43 +0000 (20:39 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-otter.rs

index b59095c3e678cb1bc1c52df124e0670ff0d1aab8..ec4f467e7b34aa428f199650329c6e34c7e8812e 100644 (file)
@@ -286,6 +286,14 @@ impl Session {
     self.api_piece_op(piece, "ungrab", json!({}))?;
   }
 
+  #[throws(AE)]
+  fn api_piece_move_synch<PI:Idx>(
+    &mut self, pieces: &mut Pieces<PI>, i: PI, pos: Pos
+  ) {
+    pieces[i].pos = pos;
+    self.api_with_piece_op_synch(pieces, i, "m", json![pos.0])?;
+  }
+
   #[throws(AE)]
   fn await_update<
     R,
@@ -514,8 +522,7 @@ impl Ctx {
     for (xi, &p) in a_pawns.iter().enumerate().take(1) {
       let xix: Coord = xi.try_into().unwrap();
       let pos = PosC([ (xix + 1) * 15, 20 ]);
-      a_pieces[p].pos = pos;
-      alice.api_with_piece_op_synch(&mut a_pieces, p, "m", json![pos.0])?;
+      alice.api_piece_move_synch(&mut a_pieces, p, pos)?;
     }
 
     alice.synchu(&mut a_pieces)?;