1 // Copyright 2020-2021 Ian Jackson and contributors to Otter
2 // SPDX-License-Identifier: AGPL-3.0-or-later
3 // There is NO WARRANTY.
12 self.su().mgmt_conn().cmd(&MC::SetFakeTime(FakeTimeSpec(Some(0))))?;
13 self.otter_resetting(&G("reset demo"))?;
15 let mut alice = self.connect_player(&self.alice)?;
16 let mut bob = self.connect_player(&self.bob)?;
18 let mut a_pieces = alice.pieces::<PIA>()?;
19 let hand = a_pieces.find_by_desc_glob(otter::hand::UNCLAIMED_HAND_DESC);
20 let hand_pos = a_pieces[hand].pos;
21 let die_a = a_pieces.find_by_desc_glob("a d2 *");
22 let die_red = a_pieces.find_by_desc_glob("a red die *");
24 let move_into_hand = |alice: &mut Session, a_pieces: &'_ mut _, p, x_off| {
25 let pos = (hand_pos + PosC::new(x_off,0))?;
26 alice.api_piece(GH::With, PuSynch(&mut (a_pieces, p)), pos)?;
29 move_into_hand(&mut alice, &mut a_pieces, die_a, -10)?;
31 alice.api_piece(GH::With, PuSynch(&mut (&mut a_pieces, hand)),
32 ("k", json!({ "opname": "claim",
33 "wrc": WRC::Unpredictable })))?;
34 move_into_hand(&mut alice, &mut a_pieces, die_red, 10)?;
36 self.su().mgmt_conn().cmd(&MC::SetFakeTime(FakeTimeSpec(Some(6000))))?;
39 alice.api_piece(GH::With, PuSynch(&mut (&mut a_pieces, die_red)),
40 ("k", json!({ "opname": "roll",
41 "wrc": WRC::UpdateSvg })))?;
43 alice.api_piece(GH::With, PuSynch(&mut (&mut a_pieces, hand)),
44 ("k", json!({ "opname": "deactivate",
45 "wrc": WRC::Unpredictable })))?;
52 fn tests(mut c: Ctx) {
53 test!(c, "dice", c.dice() ?);
58 tests(Ctx::setup()?)?;