From 0173112cd5872d7138cb8bc03faa4f3118c059bf Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 7 Sep 2009 18:03:43 +0100 Subject: [PATCH] Parse vessel data in format closer to YPP output --- yarrg/Commods.pm | 19 ++++++++++--------- yarrg/source-info.txt | 36 +++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index 3ecb804..7a29edc 100644 --- a/yarrg/Commods.pm +++ b/yarrg/Commods.pm @@ -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 { diff --git a/yarrg/source-info.txt b/yarrg/source-info.txt index dc67c4e..35a13aa 100644 --- a/yarrg/source-info.txt +++ b/yarrg/source-info.txt @@ -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 -- 2.30.2