3 # helper program for determining pixmap resolution options
5 # This is part of ypp-sc-tools, a set of third-party tools for assisting
6 # players of Yohoho Puzzle Pirates.
8 # Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
24 # are used without permission. This program is not endorsed or
25 # sponsored by Three Rings.
27 use strict (qw(vars));
32 @ARGV==1 or die "You probably don't want to run this program directly.\n";
33 our ($which) = shift @ARGV;
37 our ($pctb) = $ENV{'YPPSC_PCTB_PCTB'}; die unless $pctb;
38 our ($ua)= LWP::UserAgent->new;
41 sub jparsetable ($$) {
43 my $jtab= $jobj->{$wh};
44 die "$jsonresp $wh ?" unless defined $jtab;
45 my $cns= $jtab->{'colNames'}; die "$jsonresp $wh ?" unless defined $cns;
46 my $ad= $jtab->{'arrayData'}; die "$jsonresp $wh ?" unless defined $ad;
48 foreach my $ai (@$ad) {
49 @$ai == @$cns or die "$jsonresp $wh ".scalar(@o)."?";
51 for (my $i=0; $i<@$cns; $i++) {
52 $v->{$cns->[$i]} = $ai->[$i];
60 $a->{'name'} cmp $b->{'name'};
64 sub p ($) { print $_[0] or die $!; }
67 die "$_ $& ?" if m/[^-+'"# 0-9a-z]/i;
72 my $ocean= $ENV{'YPPSC_OCEAN'}; die unless $ocean;
73 my $url= "$pctb/islands.php?oceanName=".uc $ocean;
74 my $resp= $ua->get($url);
75 die $resp->status_line unless $resp->is_success;
76 $jsonresp= $resp->content;
77 my $jobj= jsonToObj($resp->content);
78 my @arches= jparsetable($jobj, 'arches');
79 my @islands= jparsetable($jobj, 'islands');
80 # print Dumper(\@arches, \@islands);
82 foreach my $arch (sort_by_name(@arches)) {
83 # print Dumper($arch);
84 my $aname= $arch->{'name'};
85 die "$jsonresp ?" unless defined $aname;
86 ptcl($aname); p(' '); ptcl($aname); p(" {\n");
87 foreach my $island (sort_by_name(@islands)) {
88 my $iname= $island->{'name'};
89 die "$jsonresp $aname ?" unless defined $iname;
90 next unless $arch->{'id'} == $island->{'arch'};
91 p(' '); ptcl($iname); p(' '); ptcl($iname); p("\n");
96 die "$jsonresp $islands_done ?" unless $islands_done == @islands;
99 sub main__sunshinewidget () {
108 Vessel {On board a ship} {