# HG changeset patch # User "Rex Tsai " # Date 1234372767 -28800 # Node ID 6782280a886b36a3726dba29718a724e3f070377 # Parent 58b36b18809f23431d1d96c875235c8ab53be73c# Parent 0db3e2bcbd0f027fd8b8179ae309052481c51617 merged diff -r 0db3e2bcbd0f -r 6782280a886b Ikariam.pm --- a/Ikariam.pm Thu Feb 12 01:16:20 2009 +0800 +++ b/Ikariam.pm Thu Feb 12 01:19:27 2009 +0800 @@ -116,6 +116,7 @@ use YAML qw/LoadFile Dump DumpFile/; use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ; use POSIX; +use JSON;; use utf8; sub new @@ -231,67 +232,30 @@ 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, - ]); + my $res = $self->{mech}->post(sprintf("http://%s/index.php?action=WorldMap&function=getJSONArea&x_min=%d&x_max=%d&y_min=%d&y_max=%d", + $self->{server}, $x - 14, $x + 12, $y - 17, $y + 9), []); my $c; my $status = gunzip \$res->content => \$c or die "gunzip failed: $GunzipError\n"; + my $nodes = jsonToObj($c); my @islands; - # parsing xjxobj - while($c =~ /0<\/k><\/v><\/e>1<\/k><\/v><\/e>2<\/k><\/v><\/e>3<\/k><\/v><\/e>4<\/k><\/v><\/e>5<\/k><\/v><\/e>6<\/k><\/v><\/e>7<\/k><\/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 viewHomeMap -{ - 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 - or die "gunzip failed: $GunzipError\n"; - - # m[50][36]=new Array(564,1,5,'Risietia', '5', 13); - # x = 43-57 = 6 - # y = 27-41 = 6 - my @islands; - while($c =~ /m\[(\d+)\]\[(\d+)\]=new Array\((\d+),(\d+),(\d+),'(\w+)', '(\d+)', (\d+)\);/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; - - #foreach my $i (sort(keys(%island))) - #{ - # printf ("%s %s\n", $i, $island{$i}); - #} - #print("\n"); - push @islands, \%island; + print $nodes->{'data'}; + foreach my $x (keys %{$nodes->{'data'}}) { + foreach my $y (keys(%{$nodes->{data}->{$x}})) { + my %island; + $island{id} = $nodes->{data}->{$x}->{$y}[0]; + $island{x} = $x; + $island{y} = $y; + $island{name} = $nodes->{data}->{$x}->{$y}[1]; + +# $island{tradegood} = $4; +# $island{wonder} = $5; +# $island{people} = $8; + push @islands, \%island; + } } return @islands; } diff -r 0db3e2bcbd0f -r 6782280a886b city.yaml --- a/city.yaml Thu Feb 12 01:16:20 2009 +0800 +++ b/city.yaml Thu Feb 12 01:19:27 2009 +0800 @@ -37,6 +37,8 @@ - is_bacchanal: 0: set_tavern 1: build_tavern + - is_academy_enough: + 0: build_academy - is_shipyard_level_enough: 0: - is_professionalarmy_researched: @@ -51,8 +53,6 @@ 1: build_safehouse - is_wall_enough: 0: build_wall - - is_academy_enough: - 0: build_academy - is_embassy_enough: 0: - is_foreigncultures_researched: