From: Ian Jackson Date: Fri, 9 Jul 2021 18:27:15 +0000 (+0100) Subject: jstest: lower: from-pieces helper script X-Git-Tag: otter-0.7.2~192 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=4dfec358c4c8c0dcc0ea83af361160bb05e3cb63;p=otter.git jstest: lower: from-pieces helper script Signed-off-by: Ian Jackson --- diff --git a/jstest/from-pieces b/jstest/from-pieces new file mode 100755 index 00000000..78cf90af --- /dev/null +++ b/jstest/from-pieces @@ -0,0 +1,28 @@ +#!/usr/bin/perl -w + +use strict; +use JSON; +use Data::Dumper; + +my $jtext = do { undef $/; ; }; +my $data = decode_json($jtext); +#print STDERR Dumper($data); + +my @pieces = map { + my $id = $_; + my $p = $data->{$_}; + [ + $p->{z}, + $p->{zg}, + (sprintf " sp!(\"%s\", %s, %s),\n", + $id, + $p->{pinned} ? 'true' : 'false', + $p->{moveable} eq 'IfWresting' ? 'No' : $p->{moveable}) + ] +} keys %$data; + +my @sorted = sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] } @pieces; + +foreach my $p (@sorted) { + print $p->[2] or die $!; +}