From: Ian Jackson Date: Tue, 5 Jan 2021 01:38:19 +0000 (+0000) Subject: wip angle op X-Git-Tag: otter-0.2.0~23 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=bc12ca3ff9c12f40166b85f8440c2fc3efa58991;p=otter.git wip angle op Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index b00fe990..db958852 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -322,10 +322,9 @@ impl ApiPieceOp for ApiPieceMove { } } -/* #[derive(Debug,Serialize,Deserialize)] -struct ApiPieceRotate (bool); -#[post("/_/api/r", format="json", data="
")] +struct ApiPieceRotate(CompassAngle); +#[post("/_/api/rotate", format="json", data="")] #[throws(OE)] fn api_rotate(form : Json>) -> impl response::Responder<'static> { api_piece_op(form) @@ -335,20 +334,13 @@ impl ApiPieceOp for ApiPieceRotate { fn op(&self, a: ApiPieceOpArgs) -> PieceUpdateFromOp { let ApiPieceOpArgs { gs,piece, .. } = a; let pc = gs.pieces.byid_mut(piece).unwrap(); - let (pos, clamped) = self.0.clamped(gs.table_size); + pc.angle = PieceAngle::Compass(self.0); let logents = vec![]; - pc.pos = pos; - if clamped { - throw!(ApiPieceOpError::PartiallyProcessed( - PieceOpError::PosOffTable, - logents, - )); - } - let update = PieceUpdateOp::Move(self.0); + let update = PieceUpdateOp::Modify(()); (WhatResponseToClientOp::Predictable, update, logents) } -}*/ +} #[derive(Debug,Serialize,Deserialize)] struct ApiPiecePin (bool);