# HG changeset patch # User "Rex Tsai " # Date 1225693664 -28800 # Node ID 60f4ce7e1f63a0e6252b19a24c58d94c814926bc # Parent 2c2dcbcc5c4d17984e123e241bfb7d4b25342ab5 fixed warehouse level counting diff -r 2c2dcbcc5c4d -r 60f4ce7e1f63 agent.pl --- a/agent.pl Mon Nov 03 13:36:34 2008 +0800 +++ b/agent.pl Mon Nov 03 14:27:44 2008 +0800 @@ -49,9 +49,9 @@ my ($self, $city) = @_; my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); my @cities = keys(%{$self->{ikariam}->{cities}}); - my $nextCities = $#cities + 1; + my $nextCities = ($#cities + 1) + 1; - Carp::carp(sprintf("Required warehouse level %s, current is %s\n", $warehouse[$nextCities], $city->{buildings}->{warehouse})); + Carp::carp(sprintf("Required warehouse level %s for next city (%s), current is %s\n", $warehouse[$nextCities], $nextCities, $city->{buildings}->{warehouse})); return 0 if(!defined($city->{buildings}->{warehouse})); return ($city->{buildings}->{warehouse} >= $warehouse[$nextCities]) ? 1 : 0; } @@ -61,10 +61,11 @@ my ($self, $city) = @_; my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); my @cities = keys(%{$self->{ikariam}->{cities}}); + my $citiesNumber = $#cities + 1; - Carp::carp(sprintf("Required warehouse level %s, current is %s\n", $warehouse[$#cities], $city->{buildings}->{warehouse})); + Carp::carp(sprintf("Required warehouse level %s for %s cities, current is %s\n", $warehouse[$citiesNumber], $citiesNumber, $city->{buildings}->{warehouse})); return 0 if(!defined($city->{buildings}->{warehouse})); - return ($city->{buildings}->{warehouse} >= $warehouse[$#cities]) ? 1 : 0; + return ($city->{buildings}->{warehouse} >= $warehouse[$citiesNumber]) ? 1 : 0; } sub is_corruption {