From: Ian Jackson Date: Sat, 20 Mar 2021 22:58:41 +0000 (+0000) Subject: PieceMoveable: Enforce in /m api call X-Git-Tag: otter-0.5.0~596 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fd112ff473a281b14c437f986a294af36c9e964f;p=otter.git PieceMoveable: Enforce in /m api call Signed-off-by: Ian Jackson --- 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,