# HG changeset patch # User "Rex Tsai " # Date 1225557002 -28800 # Node ID ba03aa8abdb2a261855726e830d7ef853d122879 # Parent e49137521123464987b4cdc232a7ffbba2cb6487 reading Tavern's infomration diff -r e49137521123 -r ba03aa8abdb2 Ikariam.pm --- 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'}; }