type Ctx = UsualCtx;
+#[throws(Explode)]
+fn move_money<PI:Idx>(alice: &mut Session,
+ a_pieces: &mut Pieces<PI>, piece: PI,
+ qty: i32, z: &str, pos: Pos) {
+ alice.api_piece_op_single(PuSynch((&mut *a_pieces, piece)).id(), (
+ "multigrab", json!({ "n": qty, 'z': z })
+ ))?;
+
+ alice.api_piece(GH::Ungrab, PuSynch((&mut *a_pieces, piece)), pos)?;
+}
+
impl Ctx {
#[throws(Explode)]
fn multigrab(&mut self) {
alice.synchu(&mut a_pieces)?;
let bank = a_pieces.find_by_desc_glob("*400ƒ*");
- alice.api_piece_op_single(PuSynch((&mut a_pieces, bank)).id(), (
- "multigrab", json!({ "n": 399, 'z': "u000000000" })
- ))?;
- alice.api_piece(GH::Ungrab, PuSynch((&mut a_pieces, bank)), hand_pos)?;
+ move_money(&mut alice, &mut a_pieces, bank, 399, "u000000000", hand_pos)?;
alice.synchu(&mut a_pieces)?;
let _ = &mut bob;