#!/usr/bin/perl
-# Assumed initial state:
-# nats POGO, 1..5, $MAXNOC-1
-# sects
-# x>0,y>0 own 1
-# x<-1,y>0 own 2
-# x>0,y<0 own 3
-# x<-1,y<0 own 0
-# all wilderness, rest sea
-# owned sectors have 1m 1c
-# units 5 cs #0..4, 5 f1 #0..4, 5 sup #0..4, all in 1,-1 owned by 3
-
use warnings;
use strict;
sub edit_int1 {
my ($ef, $id, $key, $lob, $upb) = @_;
+ edit($ef, $id, $key, $lob + 1)
+ if $lob + 1 < $upb;
edit($ef, $id, $key, $lob);
$id = next_id($ef, $id);
edit($ef, $id, $key, $lob - 1)
- if ($lob > $INT_MIN);
+ if $lob > $INT_MIN;
$id = next_id($ef, $id);
+ edit($ef, $id, $key, $upb - 1)
+ if $upb - 1 > $lob + 1;
edit($ef, $id, $key, $upb);
$id = next_id($ef, $id);
edit($ef, $id, $key, $upb + 1)
- if ($upb < $INT_MAX);
+ if $upb < $INT_MAX;
}
sub edit_int {
setsect('11,7', 'ow', 2);
# x,y (copy)
-edit('sect', '1,7', 'L', '1,-7');
+edit('sect', '1,7', 'L', '5,-7');
edit('sect', '3,-7', 'L', '3,-7', 'L', '1,0');
# effic mobil iron gmin fertil oil uran work loyalty che pstage ptime
# des newdes
for my $key ('s', 'S') {
+ edit('sect', '6:8,4', $key, '+');
edit('sect', '6,4', $key, '+');
- edit('sect', '6,4', $key, '+');
- edit('sect', '8,4', $key, '+');
edit('sect', '8,4', $key, ',');
}
# interactive edit
iedit('sect', '3,5', 'm 2', 'a 1');
iedit('sect', '5,5', ' ');
+iedit('sect', '7:9,5', 'e 1', '', 'e 2');
# give
give('2,6', 'l', $INT_MIN);
give('4:8,6', 'c', 1);
give('6,6', 'c', $INT_MAX);
give('8,6', 'c', -1);
+for my $key (split(//, 'cmsgpidbfolhur')) {
+ give('10,6', $key, 1);
+}
# swapsector
swaps('-2,2', '2,-2');
-## Ship, plane, land unit
+## Ship, plane, land unit, nuke
-for my $ef ('ship', 'plane', 'land') {
+for my $ef ('ship', 'plane', 'land', 'nuke') {
# invalid key
edit($ef, 0, '@', 0);
# own
edit($ef, 1, 'O', $MAXNOC - 1);
edit($ef, 1, 'O', $MAXNOC);
edit($ef, 2, 'O', 2);
+ edit($ef, 4, 'O', 0, 'O', '3');
# uid (copy)
edit($ef, 3, 'U', 5, 'U', 3);
edit($ef, 0, 'U', 0, 'U', -1);
edit($ef, 3, $key, '1,-1');
}
+# ship: type
+edit('ship', 6, 't', 'lc', 'O', 1, 't', 'lc', 't', 'hc', 'g', 8, 't', 'lc');
+
# ship: effic mobil tech pstage ptime milit
edit_int('ship', 2, (
['E', 0, 100],
['m', 0, 50],
));
-# plane: effic mobil range tech
+# plane: type
+edit('plane', 6, 'T', 'mb', 'O', 1, 'T', 'mb', 'T', 'hb', 'T', 'mb');
+edit('plane', 7, 'O', 1, 'r', 255, 'T', 'hb', 'T', 'mb');
+edit('plane', 8, 'O', 1, 'T', 'hb', 'r', 255, 'T', 'f1');
+edit('plane', 12, 'T', 'ssm', 'O', 1, 'U', 13, 'U', 14, 'U', 15);
+
+# plane: effic mobil range tech harden
edit_int('plane', 2, (
['e', 0, 100],
['m', -127, 127],
['r', 0, 9],
['t', 50, 32767],
+ ['F', 0, 0],
+));
+edit_int('plane', 12, (
+ ['F', 0, 127],
));
+# land: type
+edit('land', 6, 'T', 'art', 'O', 1, 'T', 'art', 'T', 'hat', 'g', 12,
+ 'T', 'art');
+
# land: effic mobil tech harden retreat milit
edit_int('land', 2, (
['e', 0, 100],
['m', 0, 25],
));
+# nuke: type
+edit('nuke', 6, 't', '15kt', 'O', 1, 't', '15kt', 't', '50kt', 't', '15kt');
+
+# nuke: tech
+edit_int('nuke', 2, (
+ ['T', 280, 32767],
+));
+
# fleet, wing, army
sub unit_group {
my ($ef, $key) = @_;
edit($ef, 3, 'W', 513, 'W', 1030, 'W', 2);
}
+# items
+for my $ef ('ship', 'land') {
+ for my $key (split(//, 'cmsgpidBfolhur')) {
+ edit($ef, 2, $key, 1);
+ }
+}
+
# plane: flags
# Take care to have only valid bits set in final state
edit('plane', 2, 'f', 4);
# carrier
sub unit_carrier {
- my ($ef, $skey, $pkey) = @_;
- edit($ef, 2, $skey, -1, $skey, 9999);
- edit($ef, 3, $skey, 3);
- edit($ef, 4, $skey, 4, $pkey, 4);
+ my ($ef, $key1, $key2) = @_;
+ edit($ef, 2, $key1, -1, $key1, 9999);
+ edit($ef, 3, $key1, 3);
+ edit($ef, 4, $key1, 4, $key2, 4) if defined $key2;
}
unit_carrier('plane', 's', 'y');
unit_carrier('land', 'S', 'Y');
+unit_carrier('nuke', 'p');
# special case: move carrier's cargo away
edit('plane', 4, 'l', '5,1');
+# special case: load teleports to carrier
+# (previous loads already zapped fortification)
+edit('land', 4, 'S', 2);
+
+# special case: load teleports to carrier and zaps fortification
+edit('plane', 14, 's', 4);
+
# interactive edit
iedit('ship', 0, 'M 2', 'm 1', 'f 1');
iedit('ship', 0, 'R n', 'R ""');
iedit('plane', 0, 'm 2', 'y -1');
iedit('land', 0, 'M 2', 'Y -1');
+iedit('nuke', 0, 'S a', 'p -1');
## Nation