chiark / gitweb /
api: Support loose grab op
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 14 Jul 2021 15:17:45 +0000 (16:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 14 Jul 2021 15:17:45 +0000 (16:17 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/api.rs

index 60643d5c72ae1202ed94305b0df362fd723ee2c1..34646e32165a7fba1baf1ccbed7090352cc9390b 100644 (file)
@@ -283,6 +283,14 @@ api_route!{
   }
 
   impl op::Core as {
+    #[throws(ApiPieceOpError)]
+    fn conflict_loose_check(&self, gpc: &GPiece, client: ClientId)
+                            -> ContinueDespiteConflict {
+      if gpc.occult.is_active()             { throw!(Ia::Occultation    ) }
+      if gpc.moveable != PieceMoveable::Yes { throw!(Ia::PieceImmoveable) }
+      if gpc.last_released != client        { throw!(Ia::PieceHeld      ) }
+      ContinueDespiteConflict
+    }
   }
 
   impl op::Simple as {