Mercurial > eagle-eye
changeset 328:6782280a886b
merged
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 12 Feb 2009 01:19:27 +0800 |
parents | 58b36b18809f (diff) 0db3e2bcbd0f (current diff) |
children | c29c8dad0673 |
files | |
diffstat | 2 files changed, 20 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- 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 =~ /<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 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; }
--- 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: