Mercurial > eagle-eye
diff agent.pl @ 197:dbdd7dcc91c6
fixed for friendly troop and corruption
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Mon, 03 Nov 2008 03:17:43 +0800 |
parents | a6a4a48d5fda |
children | 2dfeb4371db7 |
line wrap: on
line diff
--- a/agent.pl Mon Nov 03 02:00:29 2008 +0800 +++ b/agent.pl Mon Nov 03 03:17:43 2008 +0800 @@ -47,10 +47,11 @@ sub is_warehouse_enougn_for_governorsresidence { my ($self, $city) = @_; - my @warehouse = (qw/undef 0 4 9 16 18 19 20 21 22 23 24 25/); + my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); my @cities = keys(%{$self->{ikariam}->{cities}}); - return ($city->{buildings}->{warehouse} < $warehouse[$#cities]) ? 0 : 1; + Carp::carp(sprintf("Required warehouse level %s, current is %s only\n", $warehouse[$#cities], $city->{buildings}->{warehouse})); + return ($city->{buildings}->{warehouse} > $warehouse[$#cities]) ? 0 : 1; } sub is_corruption { @@ -236,7 +237,7 @@ sub is_barracks_upgrading { my ($self, $city) = @_; - return $::i->is_barracks_upgrading($city->{id}); + return $self->{ikariam}->is_barracks_upgrading($city->{id}); } sub is_army_trainning { @@ -263,7 +264,8 @@ # navy sub is_navyExpenditure_available { - my ($self, $cityId) = @_; + my ($self, $city) = @_; + my $cityId = $city->{id}; # move this to somewhere else. my $workersRatio = { @@ -290,7 +292,9 @@ # army sub is_milityExpenditure_available { - my ($self, $cityId) = @_; + my ($self, $city) = @_; + my $cityId = $city->{id}; + # move this to somewhere else. my $workersRatio = { 'citizens' => 0.4, @@ -358,7 +362,6 @@ } DumpFile("army-dump.yaml", $cities); - # build and upgrade for cities $tree = LoadFile('city.yaml'); $cities->{$cityId}->{parse_path} = [];