We can now pass this through to a piece.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
}
}
+api_route!{
+ api_multigrab, "/_/api/multigrab",
+ struct ApiPieceMultigrab {
+ n: MultigrabQty,
+ }
+
+ as:
+ #[throws(ApiPieceOpError)]
+ fn op(&self, mut a: ApiPieceOpArgs) -> PieceUpdate {
+ if ! a.ipc.special.multigrab { throw!(Ia::BadPieceStateForOperation) }
+ let pri = a.pri()?;
+ let y = pri.fully_visible().ok_or(Ia::Occultation)?;
+ a.ipc.show(y).op_multigrab(a, pri, self.n)?
+ }
+}
+
api_route!{
api_uo, "/_/api/k",
struct ApiPieceUo {
api_wrest,
api_pin,
api_uo,
+ api_multigrab,
]
}
const QTY_FONT_SIZE: f64 = 6.;
-type Qty = u32;
+type Qty = MultigrabQty;
#[derive(Debug,Serialize,Deserialize)]
pub struct Spec {
pub zg: Generation,
}
+pub type MultigrabQty = u32;
+
// ---------- game state ----------
#[derive(Debug,Serialize,Deserialize)]
None
}
+ fn op_multigrab(&self, _: ApiPieceOpArgs, _: PieceRenderInstructions,
+ _: MultigrabQty) -> Result<PieceUpdate,ApiPieceOpError> {
+ Err(Ia::BadPieceStateForOperation)?
+ }
+
#[throws(IE)]
fn abs_bbox(&self, p: &GPiece) -> Rect {
Rect { corners: self.bbox_approx()?.corners.iter().map(