chiark / gitweb /
occult: Prevent moving occulting pieces (servr)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 15 Mar 2021 01:09:07 +0000 (01:09 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 15 Mar 2021 01:09:07 +0000 (01:09 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/api.rs

index 54ac9947282c7fe4f020a8a86c5fa8304447f0cc..9b88e294b5874a4a23f7e329d441d43979ee2a03 100644 (file)
@@ -379,14 +379,12 @@ api_route!{
 
   impl op::Core as {
     #[throws(OnlineError)]
-    fn check_held(&self, pc: &GPiece, player: PlayerId) {
+    fn check_held(&self, gpc: &GPiece, player: PlayerId) {
       // This will ensure that occultations are (in general) properly
       // updated, because the player will (have to) release the thing
       // again
-      if pc.held != Some(player) {
-        throw!(OnlineError::PieceHeld)
-      }
-      // xxx prevent moving anything that is occulting
+      if gpc.held != Some(player) { throw!(OnlineError::PieceHeld) }
+      if gpc.occult.is_active() { throw!(OE::Occultation) }
     }
   }