Mercurial > eagle-eye
changeset 203:60f4ce7e1f63
fixed warehouse level counting
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Mon, 03 Nov 2008 14:27:44 +0800 |
parents | 2c2dcbcc5c4d |
children | 95d47d69c202 |
files | agent.pl |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 {