Mercurial > eagle-eye
diff Ikariam.pm @ 172:ba03aa8abdb2
reading Tavern's infomration
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Sun, 02 Nov 2008 00:30:02 +0800 |
parents | 637314cc57ed |
children | e8a244ce5a1d |
line wrap: on
line diff
--- a/Ikariam.pm Sun Nov 02 00:12:53 2008 +0800 +++ b/Ikariam.pm Sun Nov 02 00:30:02 2008 +0800 @@ -528,10 +528,29 @@ $self->{'cities'}->{$cityId}->{maxActionPoints} = $extractor->find('//span[@id="value_maxActionPoints"]');; } +sub checkTavern { + my $self = shift; + my $cityId = shift; + + my @locations = @{$self->{'cities'}->{$cityId}->{locations}}; + # init + $self->{'cities'}->{$cityId}->{'tavern'}->{'maxValue'} = 0; + $self->{'cities'}->{$cityId}->{'tavern'}->{'iniValue'} = 0; + foreach (0..$#locations) { + if($locations[$_] eq 'tavern') { + my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=tavern&id=%d&position=%d', $self->{server}, $cityId, $_ )); + my $extractor = Ikariam::Extractor->new(content => $res->content); + if($extractor->{doc}->toString(0) =~ /maxValue : (\d+),\s+overcharge : \d+,\s+iniValue : (\d+),/) { + $self->{'cities'}->{$cityId}->{'tavern'}->{'maxValue'} = $1; + $self->{'cities'}->{$cityId}->{'tavern'}->{'iniValue'} = $2; + } + last; + } + } +} sub checkMilitaryAdvisorMilitaryMovements { my $self = shift; - # TODO my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=militaryAdvisorMilitaryMovements', $self->{server})); my $extractor = new Ikariam::Extractor(content => $res->content); @@ -793,6 +812,7 @@ $self->checkCity($cityId); $self->checkTownHall($cityId); $self->checkArmies($cityId); + $self->checkTavern($cityId); } return $self->{'cities'}; }