From: Ian Jackson Date: Sat, 21 May 2022 12:23:33 +0000 (+0100) Subject: at-currency: Make move_money a method on Session X-Git-Tag: otter-1.1.0~36 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3a930f308bbf771a3b6c6a4bf4072f8a9d1a2d36;p=otter.git at-currency: Make move_money a method on Session Signed-off-by: Ian Jackson --- diff --git a/apitest/at-currency.rs b/apitest/at-currency.rs index 2b63264a..fcb7da4f 100644 --- a/apitest/at-currency.rs +++ b/apitest/at-currency.rs @@ -6,15 +6,17 @@ use crate::*; type Ctx = UsualCtx; -#[throws(Explode)] -fn move_money(alice: &mut Session, - a_pieces: &mut Pieces, 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 Session { + #[throws(Explode)] + fn move_money(&mut self, + a_pieces: &mut Pieces, piece: PI, + qty: i32, z: &str, pos: Pos) { + self.api_piece_op_single(PuSynch((&mut *a_pieces, piece)).id(), ( + "multigrab", json!({ "n": qty, 'z': z }) + ))?; + + self.api_piece(GH::Ungrab, PuSynch((&mut *a_pieces, piece)), pos)?; + } } impl Ctx { @@ -79,7 +81,7 @@ impl Ctx { let bank = a_pieces.find_by_desc_glob("*400ƒ*"); - move_money(&mut alice, &mut a_pieces, bank, 399, "u000000000", hand_pos)?; + alice.move_money(&mut a_pieces, bank, 399, "u000000000", hand_pos)?; alice.synchu(&mut a_pieces)?; let _ = &mut bob;