--- /dev/null
+<%doc>
+
+ This is part of the YARRG website. YARRG is a tool and website
+ for assisting players of Yohoho Puzzle Pirates.
+
+ Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
+ Copyright (C) 2009 Clare Boothby
+
+ YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later).
+ The YARRG website is covered by the GNU Affero GPL v3 or later, which
+ basically means that every installation of the website will let you
+ download the source.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
+ are used without permission. This program is not endorsed or
+ sponsored by Three Rings.
+
+
+ This Mason component simply defines how to interpret capacities.
+
+</%doc>
+
+<%attr>
+</%attr>
+
+<%method preparse>
+<%args>
+$h
+</%args>
+<%perl>
+
+$_= ${ $h->{String} };
+s/^\s+//; s/\s+$//;
+
+my $res= sub {
+ my ($pct,$str) = @_;
+ push @{ $h->{Results} }, [ $pct ];
+ ${ $h->{Canon} }= "Considering expected losses of $str per league";
+};
+
+if (!m/\S/) {
+} elsif (m/^(\d{1,2}(?:\.\d{0,5})?)\%$/) {
+ $res->( $1 * 1.0, sprintf("%g%%", $1) );
+} elsif (m/^1\s*\/\s*([1-9]\d{0,4})/) {
+ $res->( 100.0/$1, sprintf("1/%d", $1) );
+} else {
+ ${ $h->{Emsg} }= "Cannot understand loss per league \`$_'.";
+ return;
+}
+
+</%perl>
+</%method>
foreach my $var (keys %ARGS) {
next unless $var =~
m/^(?: (?:route|commod|capacity)string |
+ lossperleague |
commodid |
islandid \d |
archipelago \d |
my $emsg= '';
my @results;
my @specs;
+my $canontext;
my $hooks = { Emsg => \$emsg, String => \$string,
Results => \@results, Specs => \@specs,
+ Canon => \$canontext
};
if ($chk->method_exists('preparse')) {
push @results, $results->[0];
};
-my $canontext= join ' | ', map { $_->[0] } @results;
+if (!defined $canontext) {
+ $canontext= join ' | ', map { $_->[0] } @results;
+}
if ($chk->method_exists('postquery')) {
- $hooks->{Canon}= \$canontext;
$chk->call_method('postquery', h => $hooks);
}
$prselector
$routestring => '';
$capacitystring => '';
+$lossperleague => '';
$someresults
$emsgokorprint
</%args>
my @islandids;
my %islandid2;
my ($max_volume, $max_mass);
+my $lossperleaguepct;
my $qa= \%ARGS;
size=80
</&>
+<table>
+<tr>
+<td>
+
Vessel capacity:
<&| qtextstring, qa => $qa, dbh => $dbh, prefix => 'cs',
thingstring => 'capacitystring', emsgstore => \$emsg,
&>
</&>
+<td>
+
+
+
+<td>
+Estimated loss per league:
+
+<&| qtextstring, qa => $qa, dbh => $dbh, prefix => 'll',
+ thingstring => 'lossperleague', emsgstore => \$emsg,
+ perresult => sub { ($lossperleaguepct)= @_; }
+ &>
+</&>
+
+</table>
+
% } else { #---------- dropdowns, user selects from menus ----------
% $startform->(grep {
<input type=submit name=submit value="<% $goupdate->() %>">
% my $ours= sub { $_[0] =~
-% m/^island|^archipelago|^routestring|^capacitystring|^[RT]/;
+% m/^island|^archipelago|^routestring|^capacitystring|^lossperleague|^[RT]/;
% };
<& "lookup:formhidden", ours => $ours &>
archipelagoes => \@archipelagoes,
qa => $qa,
max_mass => $max_mass,
- max_volume => $max_volume
+ max_volume => $max_volume,
+ lossperleaguepct => $lossperleaguepct
&>
</form>
% }
$qa
$max_mass
$max_volume
+$lossperleaguepct
</%args>
<&| script &>
da_pageload= Date.now();
<strong>WARNING - VESSEL CAPACITY LIMIT NOT YET IMPLEMENTED</strong>
<p>
% }
+% if (defined $lossperleaguepct) {
+<strong>WARNING - DEFINED LOSS PER LEAGUE NOT YET IMPLEMENTED</strong>
+<% $lossperleaguepct |h %>
+<p>
+% }
<%perl>