}
}
+#[derive(Debug,Serialize,Deserialize)]
+struct ApiPieceRaise {
+}
+#[post("/_/api/raise", format="json", data="<form>")]
+#[throws(OE)]
+fn api_raise(form : Json<ApiPiece<ApiPieceRaise>>)
+ -> impl response::Responder<'static> {
+ api_piece_op(form)
+}
+impl ApiPieceOp for ApiPieceRaise {
+ #[throws(GameError)]
+ fn op(&self, gs: &mut GameState, _: PlayerId, piece: PieceId,
+ _: &dyn Lens)
+ -> (PieceUpdateOp<()>, Vec<LogEntry>) {
+ let pc = gs.pieces.byid_mut(piece).unwrap();
+ pc.raised = gs.gen;
+ let update = PieceUpdateOp::Raise;
+ (update, vec![])
+ }
+}
+
#[derive(Debug,Serialize,Deserialize)]
struct ApiPieceMove (Pos);
#[post("/_/api/m", format="json", data="<form>")]
updates,
api_grab,
api_ungrab,
+ api_raise,
api_move,
])
.launch();
Insert(NS),
Modify(NS),
Move(Pos),
+ Raise,
}
impl<NS> PieceUpdateOp<NS> {
pub fn new_state(&self) -> Option<&NS> {
Insert(ns) => Some(ns),
Modify(ns) => Some(ns),
Move(_) => None,
+ Raise => None,
}
}
pub fn map_new_state<NS2,F: FnOnce(NS) -> NS2>(self, f:F)
Insert(ns) => Insert(f(ns)),
Modify(ns) => Modify(f(ns)),
Move(pos) => Move(pos),
+ Raise => Raise,
}
}
}