Mercurial > eagle-eye
diff Ikariam.pm @ 236:cf08e01f5713
merged.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 06 Nov 2008 20:36:24 +0800 |
parents | 978a949602e5 |
children | 937fc672df56 |
line wrap: on
line diff
--- a/Ikariam.pm Thu Nov 06 20:32:52 2008 +0800 +++ b/Ikariam.pm Thu Nov 06 20:36:24 2008 +0800 @@ -360,15 +360,28 @@ $position = $_ if($locations[$_] eq $type); } - if($position != -1) { - $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); - $self->{mech}->submit_form( - form_number => 1, - fields => { - amount => $self->{'cities'}->{$cityId}->{$type}->{maxValue}, - } - ); - +# Academy - inputScientists + if($position != -1 && $type eq 'academy') { + $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); + $self->{mech}->submit_form( + form_number => 1, + fields => { + s => $self->{'cities'}->{$cityId}->{$type}->{maxValue}, + } + ); + + } + +# Tavern + if($position != -1 && $type eq 'tavern') { + $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); + $self->{mech}->submit_form( + form_number => 1, + fields => { + amount => $self->{'cities'}->{$cityId}->{$type}->{maxValue}, + } + ); + } } @@ -711,6 +724,28 @@ $self->{'cities'}->{$cityId}->{maxActionPoints} = $extractor->find('//span[@id="value_maxActionPoints"]');; } +sub checkAcademy { + my $self = shift; + my $cityId = shift; + my $building = "academy"; + + my @locations = @{$self->{'cities'}->{$cityId}->{locations}}; + # init + $self->{'cities'}->{$cityId}->{$building}->{'maxValue'} = 0; + $self->{'cities'}->{$cityId}->{$building}->{'iniValue'} = 0; + foreach (0..$#locations) { + if($locations[$_] eq $building) { + my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=%s&id=%d&position=%d', $self->{server}, $building, $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}->{$building}->{'maxValue'} = $1; + $self->{'cities'}->{$cityId}->{$building}->{'iniValue'} = $2; + } + last; + } + } +} + sub checkTavern { my $self = shift; my $cityId = shift; @@ -995,6 +1030,7 @@ $self->checkTownHall($cityId); $self->checkArmies($cityId); $self->checkTavern($cityId); + $self->checkAcademy($cityId); } # $self->checkFriends(); return $self->{'cities'};