chiark / gitweb /
tests: at-hidden: wip test
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 Apr 2022 15:25:19 +0000 (16:25 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 25 Apr 2022 00:13:08 +0000 (01:13 +0100)
This currently passes, and therefore didn't repro the un-notched piece
bug which I have been trying to repro and fix.  But it's a start.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-hidden.rs [new file with mode: 0644]
apitest/atmain.rs

diff --git a/apitest/at-hidden.rs b/apitest/at-hidden.rs
new file mode 100644 (file)
index 0000000..2488326
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+#![allow(dead_code)]
+#![allow(unused_mut)]
+#![allow(unused_variables)]
+
+use crate::*;
+
+type Ctx = UsualCtx;
+
+impl Ctx {
+  #[throws(Explode)]
+  fn dice(&mut self) {
+    self.otter_resetting(&G("reset demo"))?;
+    
+    let mut alice = self.connect_player(&self.alice)?;
+    let mut bob = self.connect_player(&self.bob)?;
+
+    let mut a_pieces = alice.pieces::<PIA>()?;
+    let hand = a_pieces.find_by_desc_glob(otter::hand::UNCLAIMED_HAND_DESC);
+    let hand_pos = a_pieces[hand].pos;
+    let die_a = a_pieces.find_by_desc_glob("a d2 *");
+    let die_red = a_pieces.find_by_desc_glob("a d2 *");
+
+    let move_into_hand = |alice: &mut Session, a_pieces: &'_ mut _, p, x_off| {
+      let pos = (hand_pos + PosC::new(x_off,0))?;
+      alice.api_piece(GH::With, PuSynch(&mut (a_pieces, p)), pos)?;
+      Ok::<_,Explode>(())
+    };
+    move_into_hand(&mut alice, &mut a_pieces, die_a, -10)?;
+
+    alice.api_piece(GH::With, PuSynch(&mut (&mut a_pieces, hand)),
+                    ("k", json!({ "opname": "claim",
+                                   "wrc": WRC::Unpredictable })))?;
+    move_into_hand(&mut alice, &mut a_pieces, die_a, 10)?;
+
+    // TODO rest of this test
+  }
+}
+
+#[throws(Explode)]
+fn tests(mut c: Ctx) {
+  test!(c, "dice",                          c.dice()                   ?);
+}
+
+#[throws(Explode)]
+pub fn main() {
+  tests(Ctx::setup()?)?;
+}
index 6deb69b238cb53b29d8436735d40c81343d84e66..9ce5b36eceabb3fd2ea76638fd9a9928c5149e98 100644 (file)
@@ -686,6 +686,7 @@ impl UsualCtx {
 
 portmanteau_has!("at-otter.rs",   at_otter);
 portmanteau_has!("at-bundles.rs", at_bundles);
+portmanteau_has!("at-hidden.rs",  at_hidden);
 
 #[throws(AE)]
 fn main() { portmanteau_main("at")? }