From: Ian Jackson Date: Sun, 18 Jul 2021 20:45:38 +0000 (+0100) Subject: jstest: Copy zlevels from game into jst-lower X-Git-Tag: otter-0.7.2~42 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7493612e9cdcfbf9196930b5ab297170f8a3d508;p=otter.git jstest: Copy zlevels from game into jst-lower Signed-off-by: Ian Jackson --- diff --git a/jstest/from-pieces b/jstest/from-pieces index da644ead..9588a7cb 100755 --- a/jstest/from-pieces +++ b/jstest/from-pieces @@ -20,12 +20,12 @@ my @pieces = map { [ $p->{z}, $p->{zg}, - (sprintf " sp!(%8s, %s, %3s), // %s %s%s\n", + (sprintf " sp!(%8s, %s, %-3s, %-23s, %6d ), %s\n", "\"$id\"", $p->{pinned} ? 'true' : 'false', $p->{moveable} eq 'IfWresting' ? 'No' : $p->{moveable}, - $p->{z}, $p->{zg}, - $p->{held} ? " HELD $p->{held}" : '', + "\"$p->{z}\"", $p->{zg}, + $p->{held} ? "// HELD $p->{held}" : '', ) ] } keys %$data; diff --git a/jstest/jst-lower.rs b/jstest/jst-lower.rs index e390771c..621c2991 100644 --- a/jstest/jst-lower.rs +++ b/jstest/jst-lower.rs @@ -29,6 +29,14 @@ macro_rules! sp { zupd: ZUS::Auto, moveable: PieceMoveable::$moveable } }; + { $id:expr, $pinned:expr, $moveable:ident, $z:expr, $zg:expr } => { + StartPieceSpec { id: $id.try_into().unwrap(), pinned: $pinned, + zupd: ZUS::Spec(ZLevel { + z: $z.try_into().unwrap(), + zg: Generation($zg), + }), + moveable: PieceMoveable::$moveable } + }; } #[derive(Debug,Clone)] @@ -65,17 +73,23 @@ pub struct TestsAccumulator { #[derive(Debug,Clone)] pub enum ZUpdateSpec { Auto, + Spec(ZLevel), } use ZUpdateSpec as ZUS; impl ZUpdateSpec { - pub fn next(&self, last: &mut zcoord::Mutable, lastg: &mut Generation) + pub fn next(self, last: &mut zcoord::Mutable, lastg: &mut Generation) -> ZLevel { match self { ZUS::Auto => ZLevel { z: last.increment().unwrap(), zg: { lastg.increment(); *lastg }, }, + ZUS::Spec(zl) => { + *last = zl.z.clone_mut(); + *lastg = zl.zg; + zl + }, } } }