From fd112ff473a281b14c437f986a294af36c9e964f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 20 Mar 2021 22:58:41 +0000 Subject: [PATCH] PieceMoveable: Enforce in /m api call Signed-off-by: Ian Jackson --- daemon/api.rs | 7 ++++++- src/error.rs | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon/api.rs b/daemon/api.rs index b90e401a..147c8b38 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -76,7 +76,7 @@ impl From<&OnlineErrorResponse> for rocket::http::Status { ServerFailure(_) => Status::InternalServerError, NoClient | NoPlayer(_) | GameBeingDestroyed => Status::NotFound, - OE::PieceHeld | + OE::PieceHeld | OE::PieceImmoveable | OE::OverlappingOccultation | OE::Occultation | OE::BadPieceStateForOperation => Status::Conflict, @@ -411,6 +411,11 @@ api_route!{ // again if gpc.held != Some(player) { throw!(OnlineError::PieceHeld) } if gpc.occult.is_active() { throw!(OE::Occultation) } + if matches_doesnot!( + gpc.moveable(), + = PieceMoveable::No, + ! PieceMoveable::Yes | PieceMoveable::IfWresting, + ) { throw!(OE::PieceImmoveable) } } } diff --git a/src/error.rs b/src/error.rs index 64436285..5e639317 100644 --- a/src/error.rs +++ b/src/error.rs @@ -21,6 +21,8 @@ pub enum OnlineError { #[error("referenced piece is gone (maybe race)")] PieceHeld, #[error("improper UI operation")] + PieceImmoveable, + #[error("improper UI operation")] BadOperation, #[error("overlapping occultation")] OverlappingOccultation, -- 2.30.2