Mercurial > eagle-eye
comparison 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 |
comparison
equal
deleted
inserted
replaced
124:f8c97e5d77ab | 125:4374173bab47 |
---|---|
473 $self->{'cities'}->{$cityId}->{resources}->{gold} = $extractor->find('//span[@id="value_gold"]/text()'); | 473 $self->{'cities'}->{$cityId}->{resources}->{gold} = $extractor->find('//span[@id="value_gold"]/text()'); |
474 $self->{'cities'}->{$cityId}->{resources}->{gold} =~ s/,//g; | 474 $self->{'cities'}->{$cityId}->{resources}->{gold} =~ s/,//g; |
475 | 475 |
476 $self->{'cities'}->{$cityId}->{name} = $extractor->find('//span[@class="city"]/text()'); | 476 $self->{'cities'}->{$cityId}->{name} = $extractor->find('//span[@class="city"]/text()'); |
477 | 477 |
478 my $island = $extractor->find('//div[@id="breadcrumbs"]/a[@class="island"]'); | |
479 if($island =~ /(\w+)\[(\d+):(\d+)\]/) { | |
480 $self->{'cities'}->{$cityId}->{island}->{name} = $1; | |
481 $self->{'cities'}->{$cityId}->{island}->{x} = $2; | |
482 $self->{'cities'}->{$cityId}->{island}->{y} = $3; | |
483 $self->{'cities'}->{$cityId}->{island}->{id} = my $island = $extractor->find('//div[@id="breadcrumbs"]/a[@class="island"]/@href'); | |
484 $self->{'cities'}->{$cityId}->{island}->{id} =~ s/\?view=island&id=(\d+)/$1/; | |
485 } | |
486 | |
478 $self->{'cities'}->{$cityId}->{construction} = defined($extractor->find('//*[@class="constructionSite"]')) ? 1 : 0; | 487 $self->{'cities'}->{$cityId}->{construction} = defined($extractor->find('//*[@class="constructionSite"]')) ? 1 : 0; |
479 | 488 |
480 # maxCapacity | 489 # maxCapacity |
481 my $page = $extractor->{doc}->toString(1); | 490 my $page = $extractor->{doc}->toString(1); |
482 if($page =~ /maxCapacity : {\s+wood: (\d+),\s+wine: (\d+),\s+marble: (\d+),\s+crystal: (\d+),\s+sulfur: (\d+)\s+}/s) { | 491 if($page =~ /maxCapacity : {\s+wood: (\d+),\s+wine: (\d+),\s+marble: (\d+),\s+crystal: (\d+),\s+sulfur: (\d+)\s+}/s) { |
685 $self->{'cities'}->{$cityId}->{'citizens'}->{$citizens_type[$i]} = $values[$i]; | 694 $self->{'cities'}->{$cityId}->{'citizens'}->{$citizens_type[$i]} = $values[$i]; |
686 $self->{'cities'}->{$cityId}->{'citizens'}->{total} += $values[$i]; | 695 $self->{'cities'}->{$cityId}->{'citizens'}->{total} += $values[$i]; |
687 } | 696 } |
688 } | 697 } |
689 | 698 |
690 | |
691 sub checkArmies | 699 sub checkArmies |
692 { | 700 { |
693 my $self = shift; | 701 my $self = shift; |
694 my $cityId = shift; | 702 my $cityId = shift; |
695 my %force_types; | 703 my %force_types; |
726 # //li[@id="advMilitary"]/a[@class="normalalert"] | 734 # //li[@id="advMilitary"]/a[@class="normalalert"] |
727 # //li[@id="advResearch"]/a[@class="normalalert"] | 735 # //li[@id="advResearch"]/a[@class="normalalert"] |
728 # //li[@id="advDiplomacy"]/a[@class="normalalert"] | 736 # //li[@id="advDiplomacy"]/a[@class="normalalert"] |
729 | 737 |
730 # looking for cities | 738 # looking for cities |
731 foreach my $cityId (keys(%{$self->{'cities'}})) | 739 foreach my $cityId (keys(%{$self->{'cities'}})) { |
732 { | |
733 $self->checkCity($cityId); | 740 $self->checkCity($cityId); |
734 $self->checkTownHall($cityId); | 741 $self->checkTownHall($cityId); |
735 $self->checkArmies($cityId); | 742 $self->checkArmies($cityId); |
736 } | 743 } |
737 return $self->{'cities'}; | 744 return $self->{'cities'}; |