diff Ikariam.pm @ 125:4374173bab47

collect hometown island information.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Fri, 31 Oct 2008 00:20:41 +0800
parents 5a66fea952fe
children 3756298f8e4b
line wrap: on
line diff
--- a/Ikariam.pm	Thu Oct 30 17:25:20 2008 +0800
+++ b/Ikariam.pm	Fri Oct 31 00:20:41 2008 +0800
@@ -475,6 +475,15 @@
 
     $self->{'cities'}->{$cityId}->{name} = $extractor->find('//span[@class="city"]/text()');
 
+    my $island = $extractor->find('//div[@id="breadcrumbs"]/a[@class="island"]');
+    if($island =~ /(\w+)\[(\d+):(\d+)\]/) {
+        $self->{'cities'}->{$cityId}->{island}->{name} = $1;
+        $self->{'cities'}->{$cityId}->{island}->{x} = $2;
+        $self->{'cities'}->{$cityId}->{island}->{y} = $3;
+        $self->{'cities'}->{$cityId}->{island}->{id} = my $island = $extractor->find('//div[@id="breadcrumbs"]/a[@class="island"]/@href');
+        $self->{'cities'}->{$cityId}->{island}->{id} =~ s/\?view=island&id=(\d+)/$1/;
+    }
+    
     $self->{'cities'}->{$cityId}->{construction} = defined($extractor->find('//*[@class="constructionSite"]')) ? 1 : 0;
 
     # maxCapacity
@@ -687,7 +696,6 @@
     }
 }
 
-
 sub checkArmies
 {
     my $self = shift;
@@ -728,8 +736,7 @@
     # //li[@id="advDiplomacy"]/a[@class="normalalert"]
 
     # looking for cities
-    foreach my $cityId (keys(%{$self->{'cities'}})) 
-    {
+    foreach my $cityId (keys(%{$self->{'cities'}})) {
         $self->checkCity($cityId);
         $self->checkTownHall($cityId);
         $self->checkArmies($cityId);