Mercurial > eagle-eye
diff Ikariam.pm @ 200:e9f111057392
fixed the build new building function.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Mon, 03 Nov 2008 12:56:19 +0800 |
parents | dbdd7dcc91c6 |
children | 95d47d69c202 |
line wrap: on
line diff
--- a/Ikariam.pm Mon Nov 03 12:00:54 2008 +0800 +++ b/Ikariam.pm Mon Nov 03 12:56:19 2008 +0800 @@ -546,16 +546,27 @@ } if($position == -1) { - foreach (0..$#locations) { - # XXX - next if($_ <= 2 && ($self->{buildingIDs}->{$type} ne "workshop-fleet" && - $self->{buildingIDs}->{$type} ne "shipyard")); - if($locations[$_] eq undef) { - my $res = $self->{mech}->get(sprintf('http://%s/index.php?action=CityScreen&function=build&id=%s&position=%s&building=%d', - $self->{server}, $cityId, $_, $self->{buildingIDs}->{$type} )); - last; + my $targetPosition = undef; + if($type eq "wall") { + # 14 is wall. + $targetPosition = 14; + } else { + foreach (0..13) { + next if($_ <= 2 && ($type ne "workshop-fleet" && + $type ne "shipyard")); + + if($locations[$_] eq undef) { + $targetPosition = $_; + last; + } } } + + my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=buildingGround&id=%s&position=%s', + $self->{server}, $cityId, $targetPosition)); + my $url = + Ikariam::Extractor->new(content => $res->content)->find(sprintf('//li[@class="building %s"]//a/@href', $type)); + $self->{mech}->get($url) if(defined($url)); } else { my $res = $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); my $url = Ikariam::Extractor->new(content => $res->content)->find('//a[@title="升級建築物"]/@href');