From 5fb0d65bdee81e9672b2e7ba289572b4ec17cfe0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 5 Apr 2021 12:46:23 +0100 Subject: [PATCH] api: grab: Reformat to allow us to override bits of Core Signed-off-by: Ian Jackson --- daemon/api.rs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/daemon/api.rs b/daemon/api.rs index dc0b236c..afa09dde 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -274,25 +274,29 @@ api_route!{ struct ApiPieceGrab { } - as: - #[throws(ApiPieceOpError)] - fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { - let ApiPieceOpArgs { gs,ioccults,player,piece,ipc, .. } = a; - let gpl = gs.players.byid_mut(player)?; - let gpc = gs.pieces.byid_mut(piece)?; + impl op::Core as { + } - let logents = log_did_to_piece( - ioccults,&gs.occults, gpl,gpc,ipc, - "grasped" - )?; + impl op::Simple as { + #[throws(ApiPieceOpError)] + fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { + let ApiPieceOpArgs { gs,ioccults,player,piece,ipc, .. } = a; + let gpl = gs.players.byid_mut(player)?; + let gpc = gs.pieces.byid_mut(piece)?; - if gpc.held.is_some() { throw!(OnlineError::PieceHeld) } - gpc.held = Some(player); + let logents = log_did_to_piece( + ioccults,&gs.occults, gpl,gpc,ipc, + "grasped" + )?; + + if gpc.held.is_some() { throw!(OnlineError::PieceHeld) } + gpc.held = Some(player); - let update = PieceUpdateOp::ModifyQuiet(()); + let update = PieceUpdateOp::ModifyQuiet(()); - (WhatResponseToClientOp::Predictable, - update, logents).into() + (WhatResponseToClientOp::Predictable, + update, logents).into() + } } } -- 2.30.2