Mercurial > eagle-eye
changeset 1:f9eac5385dc0
added viewWorldMap
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Tue, 07 Oct 2008 22:56:12 +0800 |
parents | abaee7064429 |
children | 0fb73a7a0b94 |
files | Ikariam.pm scan.pl |
diffstat | 2 files changed, 36 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Ikariam.pm Tue Oct 07 22:24:46 2008 +0800 +++ b/Ikariam.pm Tue Oct 07 22:56:12 2008 +0800 @@ -3,7 +3,7 @@ use Data::Dumper; use LWP; -use LWP::Debug qw(+ -conns); +# use LWP::Debug qw(+ -conns); use HTTP::Cookies; use WWW::Mechanize; use HTML::TagParser; @@ -33,18 +33,45 @@ my $x = shift; my $y = shift; - my $res; - if(defined($x) && defined($y)) + if(!defined($x) && !defined($y)) { - $res = $self->{mech}->post(sprintf("http://%s/index.php?view=worldmap_iso", $self->{server}), [ + die('location required'); + } + + my $res = $self->{mech}->post(sprintf("http://%s/index.php?view=worldmap_iso", $self->{server}), [ xajax => 'getMapData', 'xajaxargs[]' => $x, 'xajaxargs[]' => $y, xajaxr => time, ]); - } else { - $res = $self->{mech}->get(sprintf("http://%s/index.php?view=worldmap_iso", $self->{server})); + + my $c; + my $status = gunzip \$res->content => \$c + or die "gunzip failed: $GunzipError\n"; + + my @islands; + # parsing xjxobj + while($c =~ /<cmd n="jc" t="addToMap"><xjxobj><e><k>0<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>1<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>2<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>3<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>4<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>5<\/k><v><!\[CDATA\[(\w+)\]\]><\/v><\/e><e><k>6<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><e><k>7<\/k><v><!\[CDATA\[(\d+)\]\]><\/v><\/e><\/xjxobj><\/cmd>/g) + { + my %island; + $island{id} = $3; + $island{x} = $1; + $island{y} = $2; + $island{name} = $6; + $island{tradegood} = $4; + $island{wonder} = $5; + # $7 ? + $island{people} = $8; + push @islands, \%island; } + return @islands; +} + +sub viewHomedMap +{ + my $self = shift; + + my $res = $self->{mech}->get(sprintf("http://%s/index.php?view=worldmap_iso", $self->{server})); my $c; my $status = gunzip \$res->content => \$c
--- a/scan.pl Tue Oct 07 22:24:46 2008 +0800 +++ b/scan.pl Tue Oct 07 22:56:12 2008 +0800 @@ -14,7 +14,9 @@ my $i = new Ikariam("s2.ikariam.tw", "chihchun", "c795d57d"); $i->login; -my @islands = $i->viewWorldMap(89, 60); +# my @islands = $i->viewHomeMap(); +# my @islands = $i->viewWorldMap(89, 60); +my @islands = $i->viewWorldMap(50, 34); foreach my $island (@islands) {