Mercurial > eagle-eye
comparison Ikariam.pm @ 232:978a949602e5
Auto-update Scientists numbers for Academy.
Refined the rules for safehouse, the safe house must be same or higher level then Town Hall.
Make people very happy, when the townHall is less then 16.
Build museum first then tavern
THG: changed warfare.pl
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 06 Nov 2008 20:31:05 +0800 |
parents | a5862d3f1c84 |
children | 937fc672df56 |
comparison
equal
deleted
inserted
replaced
231:c0b9604b0be9 | 232:978a949602e5 |
---|---|
358 my @locations = @{$self->{'cities'}->{$cityId}->{locations}}; | 358 my @locations = @{$self->{'cities'}->{$cityId}->{locations}}; |
359 foreach (0..$#locations) { | 359 foreach (0..$#locations) { |
360 $position = $_ if($locations[$_] eq $type); | 360 $position = $_ if($locations[$_] eq $type); |
361 } | 361 } |
362 | 362 |
363 if($position != -1) { | 363 # Academy - inputScientists |
364 $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); | 364 if($position != -1 && $type eq 'academy') { |
365 $self->{mech}->submit_form( | 365 $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); |
366 form_number => 1, | 366 $self->{mech}->submit_form( |
367 fields => { | 367 form_number => 1, |
368 amount => $self->{'cities'}->{$cityId}->{$type}->{maxValue}, | 368 fields => { |
369 } | 369 s => $self->{'cities'}->{$cityId}->{$type}->{maxValue}, |
370 ); | 370 } |
371 | 371 ); |
372 | |
373 } | |
374 | |
375 # Tavern | |
376 if($position != -1 && $type eq 'tavern') { | |
377 $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); | |
378 $self->{mech}->submit_form( | |
379 form_number => 1, | |
380 fields => { | |
381 amount => $self->{'cities'}->{$cityId}->{$type}->{maxValue}, | |
382 } | |
383 ); | |
384 | |
372 } | 385 } |
373 } | 386 } |
374 | 387 |
375 sub is_shipyard_upgrading { | 388 sub is_shipyard_upgrading { |
376 my $self = shift; | 389 my $self = shift; |
709 $self->{'cities'}->{$cityId}->{transporters}->{sum} = $extractor->find('//span[@id="value_transSum"]/text()'); | 722 $self->{'cities'}->{$cityId}->{transporters}->{sum} = $extractor->find('//span[@id="value_transSum"]/text()'); |
710 $self->{'cities'}->{$cityId}->{transporters}->{sum} =~ s/[\(|\)]//g; | 723 $self->{'cities'}->{$cityId}->{transporters}->{sum} =~ s/[\(|\)]//g; |
711 $self->{'cities'}->{$cityId}->{maxActionPoints} = $extractor->find('//span[@id="value_maxActionPoints"]');; | 724 $self->{'cities'}->{$cityId}->{maxActionPoints} = $extractor->find('//span[@id="value_maxActionPoints"]');; |
712 } | 725 } |
713 | 726 |
727 sub checkAcademy { | |
728 my $self = shift; | |
729 my $cityId = shift; | |
730 my $building = "academy"; | |
731 | |
732 my @locations = @{$self->{'cities'}->{$cityId}->{locations}}; | |
733 # init | |
734 $self->{'cities'}->{$cityId}->{$building}->{'maxValue'} = 0; | |
735 $self->{'cities'}->{$cityId}->{$building}->{'iniValue'} = 0; | |
736 foreach (0..$#locations) { | |
737 if($locations[$_] eq $building) { | |
738 my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=%s&id=%d&position=%d', $self->{server}, $building, $cityId, $_ )); | |
739 my $extractor = Ikariam::Extractor->new(content => $res->content); | |
740 if($extractor->{doc}->toString(0) =~ /maxValue : (\d+),\s+overcharge : \d+,\s+iniValue : (\d+),/) { | |
741 $self->{'cities'}->{$cityId}->{$building}->{'maxValue'} = $1; | |
742 $self->{'cities'}->{$cityId}->{$building}->{'iniValue'} = $2; | |
743 } | |
744 last; | |
745 } | |
746 } | |
747 } | |
748 | |
714 sub checkTavern { | 749 sub checkTavern { |
715 my $self = shift; | 750 my $self = shift; |
716 my $cityId = shift; | 751 my $cityId = shift; |
717 | 752 |
718 my @locations = @{$self->{'cities'}->{$cityId}->{locations}}; | 753 my @locations = @{$self->{'cities'}->{$cityId}->{locations}}; |
993 foreach my $cityId (keys(%{$self->{'cities'}})) { | 1028 foreach my $cityId (keys(%{$self->{'cities'}})) { |
994 $self->checkCity($cityId); | 1029 $self->checkCity($cityId); |
995 $self->checkTownHall($cityId); | 1030 $self->checkTownHall($cityId); |
996 $self->checkArmies($cityId); | 1031 $self->checkArmies($cityId); |
997 $self->checkTavern($cityId); | 1032 $self->checkTavern($cityId); |
1033 $self->checkAcademy($cityId); | |
998 } | 1034 } |
999 # $self->checkFriends(); | 1035 # $self->checkFriends(); |
1000 return $self->{'cities'}; | 1036 return $self->{'cities'}; |
1001 } | 1037 } |
1002 | 1038 |