chiark / gitweb /
WIP new class and ordering data
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 29 Oct 2009 18:16:16 +0000 (18:16 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 29 Oct 2009 18:16:16 +0000 (18:16 +0000)
yarrg/Commods.pm
yarrg/source-info.txt
yarrg/update-master-info

index f74571d..a405f75 100644 (file)
@@ -98,6 +98,9 @@ our (%pctb_commodmap,@pctb_commodmap);
 my %colours; # eg $colours{'c'}{'black'}= $sources
 my (@rawcm, @nocm); # eg $rawcm[0]='fine rum'; $rawcm[1]='fine %c cloth'
 
 my %colours; # eg $colours{'c'}{'black'}= $sources
 my (@rawcm, @nocm); # eg $rawcm[0]='fine rum'; $rawcm[1]='fine %c cloth'
 
+my %colour_ordvals; # $colour_ordvals{'green'}= '30';
+my %commodclasses; # $commodclasses{'dye'}= '3';
+
 # IMPORTANT
 #  when extending the format of source-info in a non-backward
 #  compatible way, be sure to update update-master-info too.
 # IMPORTANT
 #  when extending the format of source-info in a non-backward
 #  compatible way, be sure to update update-master-info too.
@@ -116,11 +119,22 @@ sub parse_info1 ($$$) {
        s/\s+$//;
        if (m/^\%(\w+)$/) {
            my $colourkind= $1;
        s/\s+$//;
        if (m/^\%(\w+)$/) {
            my $colourkind= $1;
-           @ctx= (sub { $colours{$colourkind}{lc $_} .= $src; });
+           @ctx= (sub {
+               m/^(\S[^\t@]+\S)(?:\t+\@(\d+))?$/ or die;
+               my ($colour,$order)=$1;
+               $colours{$colourkind}{$colour} .= $src;
+               $colour_ordvals{$colourkind}{$colour}= $order
+                   if defined $order;
+           });
        } elsif (m/^commods$/) {
            @ctx= (sub { push @rawcm, lc $_; });
        } elsif (m/^nocommods$/) {
            @ctx= (sub { push @nocm, lc $_; });
        } elsif (m/^commods$/) {
            @ctx= (sub { push @rawcm, lc $_; });
        } elsif (m/^nocommods$/) {
            @ctx= (sub { push @nocm, lc $_; });
+       } elsif (m/^commodclasses$/) {
+           @ctx= (sub {
+               die unless m/^\*([-a-z]+)$/;
+               $commodclasses{$1}= scalar keys %commodclasses;
+           });
        } elsif (m/^ocean (\w+)$/) {
            my $ocean= $1;
            keys %{ $oceans{$ocean} };
        } elsif (m/^ocean (\w+)$/) {
            my $ocean= $1;
            keys %{ $oceans{$ocean} };
@@ -176,35 +190,53 @@ sub parse_info1 ($$$) {
     %commods= ();
     my $ca;
     $ca= sub {
     %commods= ();
     my $ca;
     $ca= sub {
-       my ($s,$ss) = @_;
+       my ($s,$ss,$ordbase) = @_;
 #print "ca($s)\n";
        if ($s !~ m/\%(\w+)/) {
            my ($name, $props) = $s =~
 #print "ca($s)\n";
        if ($s !~ m/\%(\w+)/) {
            my ($name, $props) = $s =~
-               /^(\S[^\t]*\S)(?:\t+(\S[^\t]*\S))?$/
+               /^(\S[^\t]*\S)(?:\t+(\S.*\S))?$/
                or die "bad commodspec $s";
            return if grep { $name eq $_ } @nocm;
            my $ucname= ucfirst $name;
            $commods{$ucname}{Srcs} .= $ss;
            my $c= $commods{$ucname};
            $c->{Volume}= 1000;
                or die "bad commodspec $s";
            return if grep { $name eq $_ } @nocm;
            my $ucname= ucfirst $name;
            $commods{$ucname}{Srcs} .= $ss;
            my $c= $commods{$ucname};
            $c->{Volume}= 1000;
+           my ($ordval, $ordclassval);
            foreach my $prop (defined $props ? split /\s+/, $props : ()) {
                if ($prop =~ m/^([1-9]\d*)(k?)g$/) {
                    $c->{Mass}= $1 * ($2 ? 1000 : 1);
            foreach my $prop (defined $props ? split /\s+/, $props : ()) {
                if ($prop =~ m/^([1-9]\d*)(k?)g$/) {
                    $c->{Mass}= $1 * ($2 ? 1000 : 1);
-               } elsif ($prop =~m/^([1-9]\d*)l$/) {
+               } elsif ($prop =~ m/^([1-9]\d*)l$/) {
                    $c->{Volume}= $1 * 1000;
                    $c->{Volume}= $1 * 1000;
+               } elsif ($prop =~ m/^\*([-a-z]+)$/) {
+                   $c->{Class}= $1;
+                   die "$1" unless exists $commodclasses{$1};
+                   $ordclassval= $commodclasses{$1} * 10000;
+               } elsif ($prop =~ m/^\@(\d+)$/) {
+                   $ordval= $1;
                } else {
                    die "unknown property $prop for $ucname";
                }
            }
                } else {
                    die "unknown property $prop for $ucname";
                }
            }
+           if (defined $ordbase && defined $ordval && defined $ordclassval) {
+               $ordval += $ordbase + $ordval + $ordclassval;
+               $c->{Ordval}= $ordval;
+#print STDERR "ordval $name $ordval\n";
+           } else {
+#print STDERR "ordval $name NONE\n";
+            }
            return;
        }
        die "unknown $&" unless defined $colours{$1};
        my ($lhs,$pctlet,$rhs)= ($`,$1,$');
        foreach my $c (keys %{ $colours{$pctlet} }) {
            return;
        }
        die "unknown $&" unless defined $colours{$1};
        my ($lhs,$pctlet,$rhs)= ($`,$1,$');
        foreach my $c (keys %{ $colours{$pctlet} }) {
-           &$ca($lhs.$c.$rhs, $ss .'%'. $colours{$pctlet}{$c});
+           my $ordcolour= $colour_ordvals{$c};
+           &$ca($lhs.$c.$rhs,
+                $ss .'%'. $colours{$pctlet}{$c},
+                defined($ordbase) && defined($ordcolour)
+                    ? $ordbase+$ordcolour : undef);
        }
     };
        }
     };
-    foreach (@rawcm) { &$ca($_,$src); }
+    foreach (@rawcm) { &$ca($_,$src,0); }
 }
 
 sub parse_info_clientside () {
 }
 
 sub parse_info_clientside () {
index 88b9311..9a33278 100644 (file)
@@ -31,15 +31,26 @@ shot
  medium        3
  large 4
 
  medium        3
  large 4
 
+commodclasses
+ *dye
+ *cloth
+ *forageables
+ *paint
+ *ship-supplies
+ *basic-commodities
+ *enamel
+ *minerals
+ *herbs
+
 commods
  kraken's blood                1kg
 commods
  kraken's blood                1kg
- %c dye                        1kg
- %c enamel             5kg
- %c paint              1200g 1l
+ %c dye                        1kg             *dye
+ %c enamel             5kg             *enamel
+ %c paint              1200g 1l        *paint
 
 
- %c cloth              700g
- fine %c cloth         700g
- sail cloth            700g
+ %c cloth              700g            *cloth
+ fine %c cloth         700g            *cloth
+ sail cloth            700g            *cloth
 
 nocommods
  black dye
 
 nocommods
  black dye
@@ -74,15 +85,15 @@ nocommods
  yellow
 
 commods
  yellow
 
 commods
- %g gems               10kg
- diamonds              10kg
- emeralds              10kg
- moonstones            10kg
- opals                 10kg
- pearls                        10kg
- rubies                        10kg
- sapphires             10kg
- topazes               10kg
+ %g gems               10kg            *forageables
+ diamonds              10kg            *forageables
+ emeralds              10kg            *forageables
+ moonstones            10kg            *forageables
+ opals                 10kg            *forageables
+ pearls                        10kg            *forageables
+ rubies                        10kg            *forageables
+ sapphires             10kg            *forageables
+ topazes               10kg            *forageables
 
 %g
  amber
 
 %g
  amber
@@ -97,62 +108,62 @@ commods
  tigereye
 
 commods
  tigereye
 
 commods
- swill                 1kg
- grog                  1kg
- fine rum              1kg
-
- broom flower          200g
- butterfly weed                100g
- cowslip               700g
- elderberries          700g
- indigo                        700g
- iris root             300g
- lily of the valley    300g
- lobelia               200g
- madder                        400g
- nettle                        300g
- old man's beard       800g
- pokeweed berries      300g
- sassafras             500g
- weld                  300g
- yarrow                        200g
-
- bananas               125kg 100l
- coconuts              125kg 100l
- limes                 125kg 100l
- mangos                        125kg 100l
- pineapples            125kg 100l
-
- carambolas            125kg 100l
- durians               125kg 100l
- passion fruit         125kg 100l
- pomegranates          125kg 100l
- rambutan              125kg 100l
-
- chalcocite            5700g
- cubanite              4700g
- gold nuggets          400g
- leushite              4400g
- lorandite             5500g
- masuyite              5100g
- papagoite             3300g
- serandite             3400g
- sincosite             3000g
- tellurium             6200g
- thorianite            100g
-
- small cannon balls    7100g
- medium cannon balls   14200g 2l
- large cannon balls    21300g 3l
-
- hemp                  125kg 250l
- hemp oil              1kg
- iron                  7800g
- lacquer               1kg
- stone                 2600g
- sugar cane            50kg 100l
- varnish               1kg
- wood                  175kg 250l
+ swill                 1kg             *ship-supplies @10
+ grog                  1kg             *ship-supplies @20
+ fine rum              1kg             *ship-supplies @30
+
+ broom flower          200g            *herbs
+ butterfly weed                100g            *herbs
+ cowslip               700g            *herbs
+ elderberries          700g            *herbs
+ indigo                        700g            *herbs
+ iris root             300g            *herbs
+ lily of the valley    300g            *herbs
+ lobelia               200g            *herbs
+ madder                        400g            *herbs
+ nettle                        300g            *herbs
+ old man's beard       800g            *herbs
+ pokeweed berries      300g            *herbs
+ sassafras             500g            *herbs
+ weld                  300g            *herbs
+ yarrow                        200g            *herbs
+
+ bananas               125kg 100l      *forageables
+ coconuts              125kg 100l      *forageables
+ limes                 125kg 100l      *forageables
+ mangos                        125kg 100l      *forageables
+ pineapples            125kg 100l      *forageables
+
+ carambolas            125kg 100l      *forageables
+ durians               125kg 100l      *forageables
+ passion fruit         125kg 100l      *forageables
+ pomegranates          125kg 100l      *forageables
+ rambutan              125kg 100l      *forageables
+
+ chalcocite            5700g           *minerals
+ cubanite              4700g           *minerals
+ gold nuggets          400g            *minerals
+ leushite              4400g           *minerals
+ lorandite             5500g           *minerals
+ masuyite              5100g           *minerals
+ papagoite             3300g           *minerals
+ serandite             3400g           *minerals
+ sincosite             3000g           *minerals
+ tellurium             6200g           *minerals
+ thorianite            100g            *minerals
+
+ small cannon balls    7100g           *ship-supplies @60
+ medium cannon balls   14200g 2l       *ship-supplies @70
+ large cannon balls    21300g 3l       *ship-supplies @80
+
+ hemp                  125kg 250l      *basic-commodities
+ hemp oil              1kg             *basic-commodities
+ iron                  7800g           *basic-commodities
+ lacquer               1kg             *basic-commodities
+ stone                 2600g           *basic-commodities
+ sugar cane            50kg 100l       *basic-commodities
+ varnish               1kg             *basic-commodities
+ wood                  175kg 250l      *basic-commodities
 
 
 client ypp-sc-tools yarrg
 
 
 client ypp-sc-tools yarrg
index e2b0973..c668745 100755 (executable)
@@ -95,7 +95,7 @@ sub process_some_info ($$$) {
            next if $h =~ m/^nocommods/;
        }
        next if $sfn =~ m/source-info/ && $h =~ m/^ocean\b/;
            next if $h =~ m/^nocommods/;
        }
        next if $sfn =~ m/source-info/ && $h =~ m/^ocean\b/;
-       next if $h =~ m/^client|^vessels|^shot\b/;
+       next if $h =~ m/^client|^vessels|^shot\b|^commodclasses/;
 
        print $df $_, "\n" or die $!;
     }
 
        print $df $_, "\n" or die $!;
     }