Mercurial > eagle-eye
changeset 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 | c0b9604b0be9 |
children | b7ea7c43dbad |
files | Ikariam.pm agent.pl city.yaml overall.yaml scan.pl warfare.pl |
diffstat | 6 files changed, 97 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/Ikariam.pm Wed Nov 05 03:08:16 2008 +0800 +++ b/Ikariam.pm Thu Nov 06 20:31:05 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'};
--- a/agent.pl Wed Nov 05 03:08:16 2008 +0800 +++ b/agent.pl Thu Nov 06 20:31:05 2008 +0800 @@ -63,7 +63,16 @@ sub is_safehouse_enough { my ($self, $city) = @_; return 0 if(!defined($city->{buildings}->{safehouse})); - return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1); + + # build the higgest safehouse. + # maybe we should have more then 4 towns, then we consider that we should upgrade safehouse at level 20. + # return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1) + # if($$city->{buildings}->{townHall} >= 20); + # return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1); + + # Safehouse must be same level as townHall, + # Maybe one level higher is better. + return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1); } sub is_warehouse_enough { @@ -107,7 +116,7 @@ my ($self, $city) = @_; return ($city->{growth} >= 5 ? 1 : 0) - if($city->{buildings}->{townHall} <= 10); + if($city->{buildings}->{townHall} <= 16); return 1 if($city->{buildings}->{townHall} >= 20); @@ -379,6 +388,9 @@ # build spy $i->buildSpy('spy', $cityId); + # enlarge the scientist number. + $i->set("academy", $cityId); + $i->set("tavern", $cityId); # build military! $tree = LoadFile('military.yaml');
--- a/city.yaml Wed Nov 05 03:08:16 2008 +0800 +++ b/city.yaml Thu Nov 06 20:31:05 2008 +0800 @@ -24,7 +24,11 @@ 1: build_townHall - is_happiness: 0: - - is_winepress_researched: + - is_museum_enough: + 0: + - is_culturalexchange_resaerched: + 1: build_museum + - is_winepress_researched: 1: - is_tavern_available: 0: build_tavern
--- a/overall.yaml Wed Nov 05 03:08:16 2008 +0800 +++ b/overall.yaml Thu Nov 06 20:31:05 2008 +0800 @@ -28,5 +28,5 @@ # 希臘火, 建造噴火船 - is_greekfire_researched: 0: research_seafaring - + 1: run_defence
--- a/scan.pl Wed Nov 05 03:08:16 2008 +0800 +++ b/scan.pl Thu Nov 06 20:31:05 2008 +0800 @@ -76,32 +76,6 @@ } } -our $i = new Ikariam($::server, $::user, $::pass); - -if($#ARGV == 1) { - $i->login; - my @islands = $i->viewWorldMap($ARGV[0], $ARGV[1]); - saveIslands(@islands); - $i->logout; -} elsif($#ARGV == 0) { - $i->login; - my $island = $ARGV[0]; - my @cities = $i->viewIsland($island); - saveCities($island, @cities); - $i->logout; -} elsif($#ARGV == -1) { - $i->login; - my $cities = $i->check; - foreach my $cityId (keys(%$cities)) { - printf("%s %s\n", $cities->{$cityId}->{island}->{x}, $cities->{$cityId}->{island}->{y}); - my @islands = $i->viewWorldMap( $cities->{$cityId}->{island}->{x}, $cities->{$cityId}->{island}->{y}); - saveIslands(@islands); - } - $i->logout; -} else { - die("Usage: $0\nUsage: $0 x y\n"); -} - sub saveIslands { my @islands = @_; @@ -121,7 +95,7 @@ # scanning the island if($island->time le (time - 30*60*6)) { - my @cities = $i->viewIsland($h_island->{id}); + my @cities = $::i->viewIsland($h_island->{id}); saveCities($h_island->{id}, @cities); $island->set('time', time); @@ -130,4 +104,33 @@ } } -# $i->getCityInfo(); + + +local $SIG{ALRM} = sub { die "timeout\n" }; +alarm 3; +our $i = new Ikariam($::server, $::user, $::pass); + +if($#ARGV == 1) { + $i->login; + my @islands = $i->viewWorldMap($ARGV[0], $ARGV[1]); + saveIslands(@islands); + $i->logout; +} elsif($#ARGV == 0) { + $i->login; + my $island = $ARGV[0]; + my @cities = $i->viewIsland($island); + saveCities($island, @cities); + $i->logout; +} elsif($#ARGV == -1) { + $i->login; + my $cities = $i->check; + # random + foreach my $cityId (keys(%$cities)) { + printf("%s %s\n", $cities->{$cityId}->{island}->{x}, $cities->{$cityId}->{island}->{y}); + my @islands = $i->viewWorldMap( $cities->{$cityId}->{island}->{x}, $cities->{$cityId}->{island}->{y}); + saveIslands(@islands); + } + $i->logout; +} else { + die("Usage: $0\nUsage: $0 x y\n"); +}