From 5df1a21a8f7ad18ade3a97b9ccf26bdcf335edd2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 11 Oct 2009 18:23:50 +0100 Subject: [PATCH] WIP routesearch: add new UI; make enter_route capable of rejecting arches, etc --- yarrg/web/check_islandstring | 58 +++++++++++++++++++++++++++ yarrg/web/enter_advrouteopts | 2 + yarrg/web/enter_route | 15 +++++-- yarrg/web/lookup | 1 + yarrg/web/query_route | 3 -- yarrg/web/query_routesearch | 78 ++++++++++++++++++++++++++++++++++++ 6 files changed, 150 insertions(+), 7 deletions(-) create mode 100644 yarrg/web/check_islandstring create mode 100644 yarrg/web/query_routesearch diff --git a/yarrg/web/check_islandstring b/yarrg/web/check_islandstring new file mode 100644 index 0000000..e8664d5 --- /dev/null +++ b/yarrg/web/check_islandstring @@ -0,0 +1,58 @@ +<%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 + 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 . + + 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 look up island names. + It is called by qtextstring. + + + +<%attr> +multiple => 1 +maxambig => 5 + + +<%method sqlstmt> + SELECT islandname,islandid,NULL + FROM islands WHERE islandname LIKE ? + + +<%method nomatch> + no island matches "<% $ARGS{spec} |h %>" + + +<%method ambiguous> + ambiguous island "<% $ARGS{spec} |h %>", + could be <% $ARGS{couldbe} |h %> + + +<%method manyambig> +   + diff --git a/yarrg/web/enter_advrouteopts b/yarrg/web/enter_advrouteopts index 1e03733..2a5eff0 100644 --- a/yarrg/web/enter_advrouteopts +++ b/yarrg/web/enter_advrouteopts @@ -88,4 +88,6 @@ Expected losses: size=9 +<% $m->content %> + diff --git a/yarrg/web/enter_route b/yarrg/web/enter_route index c21d967..fbdf2dc 100644 --- a/yarrg/web/enter_route +++ b/yarrg/web/enter_route @@ -48,16 +48,23 @@ $archipelagoes_r %#---------- textbox, user enters route as string ---------- % if (!$qa->{Dropdowns}) { -<% $enterwhat %> (islands, or archipelagoes, separated by |s or commas; - abbreviations are OK):
+<% $enterwhat %> +% if (defined($archipelagoes_r)) { +(islands, or archipelagoes, +% } else { +(islands +% } +separated by |s or commas; abbreviations are OK):
<&| qtextstring, qa => $qa, dbh => $dbh, emsgstore => $emsg_r, - thingstring => 'routestring', prefix => 'rl', + thingstring => defined($archipelagoes_r) ? 'routestring' : 'islandstring', + prefix => 'rl', onresults => sub { foreach (@_) { my ($canonname, $island, $arch) = @$_; push @$islandids_r, $island; - push @$archipelagoes_r, defined $island ? undef : $arch; + push @$archipelagoes_r, defined $island ? undef : $arch + if defined $archipelagoes_r; } } &> diff --git a/yarrg/web/lookup b/yarrg/web/lookup index 7af431c..93e44d4 100755 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -58,6 +58,7 @@ my %styles; Values => [ [ 'route', 'Trades for route' ], [ 'commod', 'Prices for commodity' ], [ 'offers', 'Offers at location' ], + [ 'routesearch', 'Find profitable route' ], [ 'age', 'Data age' ] ] }, { Name => 'BuySell', Before => '', diff --git a/yarrg/web/query_route b/yarrg/web/query_route index 53167ac..7871c3d 100644 --- a/yarrg/web/query_route +++ b/yarrg/web/query_route @@ -50,9 +50,6 @@ my $emsg; my @warningfs; my @archipelagoes; my @islandids; -my ($max_volume, $max_mass); -my $lossperleaguepct; -my $capital; my $qa= \%ARGS; diff --git a/yarrg/web/query_routesearch b/yarrg/web/query_routesearch new file mode 100644 index 0000000..53128f6 --- /dev/null +++ b/yarrg/web/query_routesearch @@ -0,0 +1,78 @@ +<%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 + 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 . + + 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 generates the core of the `routesearch' query. + + + +<%args> +$quri +$dbh +$capacitystring => ''; +$lossperleague => ''; +$capitalstring => ''; +$emsgokorprint + + +<%perl> +my $emsg; +my @warningfs; +my @islandids; + +my $qa= \%ARGS; +my $routeparams= { EmsgRef => \$emsg }; +my $maxdist; + + +

Find most profitable routes and trades

+ +% if ($qa->{Dropdowns}) { +This feature is not available from the "drop down menus" interface. +% } else { + +
+ +<& enter_route, qa=>$qa, dbh=>$dbh, emsg_r=>\$emsg, warningfs_r=>\@warningfs, + enterwhat => 'Enter starting point(s)', + islandids_r => \@islandids, archipelagoes_r => undef + &> + +<&| enter_advrouteopts, qa=>$qa, dbh=>$dbh, routeparams=>$routeparams &> + + Something: + <&| qtextstring, qa => $qa, dbh => $dbh, prefix => 'ml', + thingstring => 'capitalstring', emsgstore => \$emsg, + onresults => sub { ($maxdist)= @_; } &> + + + + +% } -- 2.30.2