From bc12ca3ff9c12f40166b85f8440c2fc3efa58991 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 5 Jan 2021 01:38:19 +0000 Subject: [PATCH] wip angle op Signed-off-by: Ian Jackson --- daemon/api.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) 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); -- 2.30.2