Mercurial > eagle-eye
comparison 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 |
comparison
equal
deleted
inserted
replaced
199:b33c8dbe9b04 | 200:e9f111057392 |
---|---|
544 foreach (0..$#locations) { | 544 foreach (0..$#locations) { |
545 $position = $_ if($locations[$_] eq $type); | 545 $position = $_ if($locations[$_] eq $type); |
546 } | 546 } |
547 | 547 |
548 if($position == -1) { | 548 if($position == -1) { |
549 foreach (0..$#locations) { | 549 my $targetPosition = undef; |
550 # XXX | 550 if($type eq "wall") { |
551 next if($_ <= 2 && ($self->{buildingIDs}->{$type} ne "workshop-fleet" && | 551 # 14 is wall. |
552 $self->{buildingIDs}->{$type} ne "shipyard")); | 552 $targetPosition = 14; |
553 if($locations[$_] eq undef) { | 553 } else { |
554 my $res = $self->{mech}->get(sprintf('http://%s/index.php?action=CityScreen&function=build&id=%s&position=%s&building=%d', | 554 foreach (0..13) { |
555 $self->{server}, $cityId, $_, $self->{buildingIDs}->{$type} )); | 555 next if($_ <= 2 && ($type ne "workshop-fleet" && |
556 last; | 556 $type ne "shipyard")); |
557 | |
558 if($locations[$_] eq undef) { | |
559 $targetPosition = $_; | |
560 last; | |
561 } | |
557 } | 562 } |
558 } | 563 } |
564 | |
565 my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=buildingGround&id=%s&position=%s', | |
566 $self->{server}, $cityId, $targetPosition)); | |
567 my $url = | |
568 Ikariam::Extractor->new(content => $res->content)->find(sprintf('//li[@class="building %s"]//a/@href', $type)); | |
569 $self->{mech}->get($url) if(defined($url)); | |
559 } else { | 570 } else { |
560 my $res = $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); | 571 my $res = $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); |
561 my $url = Ikariam::Extractor->new(content => $res->content)->find('//a[@title="升級建築物"]/@href'); | 572 my $url = Ikariam::Extractor->new(content => $res->content)->find('//a[@title="升級建築物"]/@href'); |
562 $self->{mech}->get($url) if(defined($url)); | 573 $self->{mech}->get($url) if(defined($url)); |
563 } | 574 } |