chiark / gitweb /
Parse vessel data in format closer to YPP output
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 7 Sep 2009 17:03:43 +0000 (18:03 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 7 Sep 2009 17:03:43 +0000 (18:03 +0100)
yarrg/Commods.pm
yarrg/source-info.txt

index 3ecb804..7a29edc 100644 (file)
@@ -105,16 +105,17 @@ sub parse_info1 ($$) {
            });
        } 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
+               return if m/^[-+|]+$/;
+               m/^ \| \s* ([A-Z][a-z\ ]+[a-z]) \s*
+                   \| \s* (small|medium|large) \s*
+                   \| \s* ([1-9][0-9,]+) \s*
+                   \| \s* ([1-9][0-9,]+) \s*
+                   \| $/x
                    or die;
-               $vessels{$1}= {
-                   Shot => $2,
-                   Volume => $3,
-                   Mass => $4,
-               };
+               my $name= $1;
+               my $v= { Shot => $2, Volume => $3, Mass => $4 };
+               foreach my $vm (qw(Volume Mass)) { $v->{$vm} =~ s/,//g; }
+               $vessels{$name}= $v;
            });
        } elsif (m/^shot$/) {
            @ctx= (sub {
index dc67c4e..35a13aa 100644 (file)
@@ -1,16 +1,30 @@
 
 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
+#|   Ship Name    |Gun Size|Volume | Mass  |
+ |Sloop           |small   |20,250 |13,500 |
+ |----------------+--------+-------+-------|
+ |Cutter          |small   |60,750 |40,500 |
+ |----------------+--------+-------+-------|
+ |Dhow            |medium  |20,250 |13,500 |
+ |----------------+--------+-------+-------|
+ |Longship        |small   |20,250 |13,500 |
+ |----------------+--------+-------+-------|
+ |Baghlah         |medium  |27,000 |18,000 |
+ |----------------+--------+-------+-------|
+ |Merchant brig   |medium  |135,000|90,000 |
+ |----------------+--------+-------+-------|
+ |War brig        |medium  |81,000 |54,000 |
+ |----------------+--------+-------+-------|
+ |Merchant galleon|large   |405,000|270,000|
+ |----------------+--------+-------+-------|
+ |Xebec           |medium  |182,250|121,500|
+ |----------------+--------+-------+-------|
+ |War frigate     |large   |324,000|216,000|
+ |----------------+--------+-------+-------|
+ |Grand frigate   |large   |810,000|540,000|
+# From http://yppedia.puzzlepirates.com/Ship; when updating,
+# delete unused columns and check heading is the same as above.
+# If fields reordered must change parser in Commods.pm.
 
 shot
  small 2