From: Ian Jackson Date: Sat, 31 Oct 2009 20:32:21 +0000 (+0000) Subject: Merge branch 'stable-5.x' X-Git-Tag: 6.0~24 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=commitdiff_plain;h=e85ef56a3b2eff647efc77e44ba5ba0a19e53393;hp=18bff492748999fe28f474cea854f0fd26d6394f;p=ypp-sc-tools.db-test.git Merge branch 'stable-5.x' --- diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index e63126a..5161af2 100644 --- a/yarrg/Commods.pm +++ b/yarrg/Commods.pm @@ -94,12 +94,16 @@ our %commods; # eg $commods{'Fine black cloth'}{Srcs}= $sources; # eg $commods{'Fine black cloth'}{Mass}= 700 [g] # eg $commods{'Fine black cloth'}{Volume}= 1000 [ml] +# eg $commods{'Fine black cloth'}{Ordval}= 203921 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 %colour_ordvals; # $colour_ordvals{'c'}{'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. @@ -118,11 +122,24 @@ sub parse_info1 ($$$) { 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,$2); + $colours{$colourkind}{$colour} .= $src; + if (defined $order) { + $order =~ s/^(\d+)\+$/ $1 + $. * 10 /e; + $colour_ordvals{$colourkind}{$colour}= $order; + } + }); } 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} }; @@ -177,36 +194,56 @@ sub parse_info1 ($$$) { %commods= (); my $ca; + my $lnoix=0; $ca= sub { - my ($s,$ss) = @_; -#print "ca($s)\n"; + my ($s,$ss,$ordbase) = @_; +#print STDERR "ca($s,,".(defined $ordbase ? $ordbase : '?').")\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; + 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); - } elsif ($prop =~m/^([1-9]\d*)l$/) { + } elsif ($prop =~ m/^([1-9]\d*)l$/) { $c->{Volume}= $1 * 1000; + } elsif ($prop =~ m/^\*([-a-z]+)$/) { + $c->{Class}= $1; + die "$1" unless exists $commodclasses{$1}; + $ordclassval= 1e7 + $commodclasses{$1} * 1e7; + } elsif ($prop =~ m/^\@(\d+\+?)$/) { + $ordval= $1; + $ordval =~ s/^(\d+)\+$/ $1 + $lnoix * 10 /e; } else { die "unknown property $prop for $ucname"; } } + if (defined $ordbase && defined $ordval && defined $ordclassval) { + my $ordvalout= $ordbase + $ordval + $ordclassval; + $c->{Ordval}= $ordvalout; +#print STDERR "ordval $ordvalout $name OV=$ordval OB=$ordbase OCV=$ordclassval\n"; + } else { +#print STDERR "ordval NONE $name\n"; + } 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{$pctlet}{$c}; + &$ca($lhs.$c.$rhs, + $ss .'%'. $colours{$pctlet}{$c}, + defined($ordbase) && defined($ordcolour) + ? $ordbase+$ordcolour : undef); } }; - foreach (@rawcm) { &$ca($_,$src); } + foreach (@rawcm) { $lnoix++; &$ca($_,$src,0); } } sub parse_info_clientside () { diff --git a/yarrg/TODO b/yarrg/TODO index 8e85c93..1648c6d 100644 --- a/yarrg/TODO +++ b/yarrg/TODO @@ -28,3 +28,21 @@ initial/final stocks feature query_routesearch should show capital for each voyage query_routesearch should support ending in specific place(s) + + +USEFUL WEBSITE UI SUGGESTIONS +----------------------------- + +Change loss per league to always be percentage and not to require % to +be typed. Put % sign in HTML after the entry box ? + +Intro page. +"what can this tool do for me" +Howto page. + +15:59 font size=-3 for the license info at the bottom +would also be good + +For `arbitrage' `capital' `net cash flow' +16:13 Diziet: make them hover links where tooltips define the term? + diff --git a/yarrg/commod-results-processor b/yarrg/commod-results-processor index 37484d6..8ede371 100755 --- a/yarrg/commod-results-processor +++ b/yarrg/commod-results-processor @@ -39,7 +39,7 @@ use Commods; # $commod{'Hemp'}{Hold} our @v; -our ($commod,$stall,%commod); +our ($commod,$stall,%commod,@commods_inorder); @ARGV==1 or die "You probably don't want to run this program directly.\n"; our ($mode) = shift @ARGV; @@ -69,6 +69,7 @@ while (<>) { die "$_ ?" if m/.\D/; } ($commod,$stall) = @v; + push @commods_inorder, $commod unless exists $commod{$commod}; bs_read(Buy, 2); bs_read(Sell, 4); $commod{$commod}{Hold}= $v[6]+0 if @v>6; @@ -234,6 +235,41 @@ sub main__tsv () { write_tsv(\*STDOUT,1); } +sub undef_printable { my ($ov)= @_; defined $ov ? $ov : '?'; }; + +sub commodsinorder_print1 ($$) { + my ($keyword,$commod) = @_; + printf("%s\t%-40s %10s %s", + $keyword, + $commod, + undef_printable($commods{$commod}{Ordval}), + undef_printable($commods{$commod}{Class})) + or die $!; +} + +sub main__commodsinorder () { + parse_info_serverside(); + my $last_ov; + foreach my $commod (@commods_inorder) { + my $ov= $commods{$commod}{Ordval}; + commodsinorder_print1('found',$commod); + if (defined $ov) { + if (defined $last_ov && $ov <= $last_ov) { + print " out-of-order" or die $!; + } + $last_ov= $ov; + } + print "\n" or die $!; + } + foreach my $commod (sort { + undef_printable($commods{$a}{Ordval}) cmp + undef_printable($commods{$b}{Ordval}) + } keys %commods) { + next if exists $commod{$commod}; + commodsinorder_print1('none',$commod); + print "\n" or die $!; + } +} our ($pctb) = $ENV{'YPPSC_YARRG_PCTB'}; diff --git a/yarrg/source-info.txt b/yarrg/source-info.txt index 88b9311..4170976 100644 --- a/yarrg/source-info.txt +++ b/yarrg/source-info.txt @@ -1,3 +1,4 @@ +# -*- fundamental -*- vessels #| Ship Name |Gun Size|Volume | Mass | @@ -31,128 +32,148 @@ shot medium 3 large 4 +commodclasses + *basic-commodities + *ship-supplies + *herbs + *minerals + *cloth + *dye + *paint + *enamel + *forageables + commods - kraken's blood 1kg - %c dye 1kg - %c enamel 5kg - %c paint 1200g 1l + kraken's blood 1kg *dye @105 + %d dye 1kg *dye @0 + %enamel enamel 5kg *enamel @0 + %c paint 1200g 1l *paint @0 + + %c cloth 700g *cloth @2 + fine %c cloth 700g *cloth @5 + sail cloth 700g *cloth @150000 - %c cloth 700g - fine %c cloth 700g - sail cloth 700g +%d + red @100 + yellow @110 + blue @120 + green @130 -nocommods - black dye +%enamel + %c @0 %c - aqua - black - blue - brown - gold - green - grey - lavender - lemon - light blue - light green - lime - magenta - maroon - mint - navy - orange - peach - persimmon - pink - purple - red - rose - tan - violet - white - yellow + red @100000+ + tan @100000+ + white @100000+ + black @100000+ + grey @100000+ + yellow @100000+ + pink @100000+ + violet @100000+ + purple @100000+ + navy @100000+ + blue @100000+ + aqua @100000+ + lime @100000+ + green @100000+ + orange @100000+ + aqua @100000+ + lime @100000+ + green @100000+ + orange @100000+ + maroon @100000+ + brown @100000+ + gold @100000+ + rose @100000+ + lavender @100000+ + mint @100000+ + light green @100000+ + magenta @200000+ + lemon @200000+ + peach @200000+ + light blue @200000+ + persimmon @200000+ commods - %g gems 10kg - diamonds 10kg - emeralds 10kg - moonstones 10kg - opals 10kg - pearls 10kg - rubies 10kg - sapphires 10kg - topazes 10kg + %g gems 10kg *forageables @0 + diamonds 10kg *forageables @200000+ + emeralds 10kg *forageables @200000+ + moonstones 10kg *forageables @200000+ + opals 10kg *forageables @200000+ + pearls 10kg *forageables @200000+ + rubies 10kg *forageables @200000+ + sapphires 10kg *forageables @200000+ + topazes 10kg *forageables @200000+ %g - amber - amethyst - beryl - coral - jade - jasper - jet - lapis lazuli - quartz - tigereye + amber @200000+ + amethyst @200000+ + beryl @200000+ + coral @200000+ + jade @200000+ + jasper @200000+ + jet @200000+ + lapis lazuli @200000+ + quartz @200000+ + tigereye @200000+ 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 @0+ + grog 1kg *ship-supplies @0+ + fine rum 1kg *ship-supplies @0+ + small cannon balls 7100g *ship-supplies @0+ + medium cannon balls 14200g 2l *ship-supplies @0+ + large cannon balls 21300g 3l *ship-supplies @0+ + + 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 + + iron 7800g *basic-commodities @110 + sugar cane 50kg 100l *basic-commodities @120 + hemp 125kg 250l *basic-commodities @130 + wood 175kg 250l *basic-commodities @140 + stone 2600g *basic-commodities @150 + hemp oil 1kg *basic-commodities @160 + varnish 1kg *basic-commodities @180 + lacquer 1kg *basic-commodities @190 client ypp-sc-tools yarrg diff --git a/yarrg/update-master-info b/yarrg/update-master-info index f757455..adad34c 100755 --- a/yarrg/update-master-info +++ b/yarrg/update-master-info @@ -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/^client|^vessels|^shot\b/; + next if $h =~ m/^client|^vessels|^shot\b|^commodclasses/; print $df $_, "\n" or die $!; }