chiark / gitweb /
Vessel capacities
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 7 Sep 2009 16:55:53 +0000 (17:55 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 7 Sep 2009 16:55:53 +0000 (17:55 +0100)
yarrg/Commods.pm
yarrg/db-idempotent-populate
yarrg/source-info.txt

index 860510e33835e5e1e574ab429862f0563ecf7c2a..3ecb804de2b09e439ba5276de33a0724256e3022 100644 (file)
@@ -36,6 +36,7 @@ BEGIN {
     @EXPORT      = qw(&parse_info_clientside &fetch_with_rsync
                      &parse_info_serverside &parse_info_serverside_ocean
                      %oceans %commods %clients %routes %route_mysteries
+                     %vessels %shotname2damage
                      &parse_pctb_commodmap %pctb_commodmap @pctb_commodmap
                      &get_our_version &check_tsv_line
                      &pipethrough_prep &pipethrough_run
@@ -54,6 +55,10 @@ our %oceans; # eg $oceans{'Midnight'}{'Ruby'}{'Eta Island'}= $sources;
 our %clients; # eg $clients{'ypp-sc-tools'}= [ qw(last-page) ];
 our %routes; # eg $routes{'Midnight'}{'Orca'}{'Tinga'}= $sources  NB abbrevs!
 our %route_mysteries; # eg $route_mysteries{'Midnight'}{'Norse'}= 3
+our %vessels; # eg $vessels{'War Brig'}{Shot}='medium'
+              #    $vessels{'War Brig'}{Volume}= 81000
+              #    $vessels{'War Brig'}{Mass}= 54000
+our %shotname2damage; # eg $shotname2damage{'medium'}= 3;
 # $sources = 's[l]b';
 #       's' = Special Circumstances; 'l' = local ; B = with Bleach
 
@@ -98,6 +103,24 @@ sub parse_info1 ($$) {
                    $oceans{$ocean}{$arch}{$_} .= $src;
                };
            });
+       } elsif (m/^vessels$/) {
+           @ctx= (sub {
+               m/^ ([A-Z][a-z\ ]+[a-z]) \t\s*
+                   (small|medium|large) \t\s*
+                   (\d+) \s*\t\s*
+                   (\d+) $/x
+                   or die;
+               $vessels{$1}= {
+                   Shot => $2,
+                   Volume => $3,
+                   Mass => $4,
+               };
+           });
+       } elsif (m/^shot$/) {
+           @ctx= (sub {
+               m/^ ([a-z]+) \s+ (\d+) $/x or die;
+               $shotname2damage{$1}= $2;
+           });
        } elsif (m/^routes (\w+)$/) {
            my $ocean= $1;
            @ctx= (sub {
index 143e2ef9d518e2e733d221365c372971b3ad29e0..43a2f0d62cc22d75d920c728f63476339bfa3720 100755 (executable)
@@ -102,6 +102,13 @@ db_doall(<<END)
        dist            INTEGER                 NOT NULL,
        PRIMARY KEY (aiid, biid)
  );
+ CREATE TABLE IF NOT EXISTS vessels (
+       name            TEXT                    NOT NULL,
+       mass            INTEGER                 NOT NULL,
+       volume          INTEGER                 NOT NULL,
+       shot            INTEGER                 NOT NULL,
+       PRIMARY KEY (name)
+ );
 END
     ;
 
@@ -136,6 +143,24 @@ END
     $dbh->commit;
 }
 
+#---------- vessel types ----------
+{
+    my $idempotent= $dbh->prepare(<<'END')
+ INSERT OR REPLACE INTO vessels (name, shot, mass, volume)
+                         VALUES (?,?,?,?)
+END
+    ;
+    foreach my $name (sort keys %vessels) {
+       my $v= $vessels{$name};
+       my $shotdamage= $shotname2damage{$v->{Shot}};
+       die "no shot damage for shot $v->{Shot} for vessel $name"
+           unless defined $shotdamage;
+       my @qa= ($name, $shotdamage, map { $v->{$_} } qw(Mass Volume));
+       $idempotent->execute(@qa);
+    }
+    $dbh->commit;
+}
+
 #---------- island list ----------
 #---------- routes ----------
 # now done by yppedia-chart-parser
index c0e1deb851db5d4e4947bba021094f331d3f46d1..dc67c4ef7497ef402346323f7c2bb0fa198a5d45 100644 (file)
@@ -1,4 +1,22 @@
 
+vessels
+ Sloop                 small    20250   13500
+ Cutter                        small    60750   40500
+ Dhow                  medium   20250   13500
+ Longship              small    20250   13500
+ Baghlah               medium   27000   18000
+ Merchant brig         medium  135000   90000
+ War brig              medium   81000   54000
+ Merchant galleon      large   405000  270000
+ Xebec                 medium  182250  121500
+ War frigate           large   324000  216000
+ Grand frigate         large   810000  540000
+
+shot
+ small 2
+ medium        3
+ large 4
+
 commods
  kraken's blood                1kg
  %c dye                        1kg