Mercurial > eagle-eye
comparison agent.pl @ 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 | b7af307a222d |
comparison
equal
deleted
inserted
replaced
202:2c2dcbcc5c4d | 203:60f4ce7e1f63 |
---|---|
47 | 47 |
48 sub is_warehouse_enough { | 48 sub is_warehouse_enough { |
49 my ($self, $city) = @_; | 49 my ($self, $city) = @_; |
50 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); | 50 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); |
51 my @cities = keys(%{$self->{ikariam}->{cities}}); | 51 my @cities = keys(%{$self->{ikariam}->{cities}}); |
52 my $nextCities = $#cities + 1; | 52 my $nextCities = ($#cities + 1) + 1; |
53 | 53 |
54 Carp::carp(sprintf("Required warehouse level %s, current is %s\n", $warehouse[$nextCities], $city->{buildings}->{warehouse})); | 54 Carp::carp(sprintf("Required warehouse level %s for next city (%s), current is %s\n", $warehouse[$nextCities], $nextCities, $city->{buildings}->{warehouse})); |
55 return 0 if(!defined($city->{buildings}->{warehouse})); | 55 return 0 if(!defined($city->{buildings}->{warehouse})); |
56 return ($city->{buildings}->{warehouse} >= $warehouse[$nextCities]) ? 1 : 0; | 56 return ($city->{buildings}->{warehouse} >= $warehouse[$nextCities]) ? 1 : 0; |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 sub is_warehouse_enougn_for_governorsresidence { | 60 sub is_warehouse_enougn_for_governorsresidence { |
61 my ($self, $city) = @_; | 61 my ($self, $city) = @_; |
62 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); | 62 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); |
63 my @cities = keys(%{$self->{ikariam}->{cities}}); | 63 my @cities = keys(%{$self->{ikariam}->{cities}}); |
64 | 64 my $citiesNumber = $#cities + 1; |
65 Carp::carp(sprintf("Required warehouse level %s, current is %s\n", $warehouse[$#cities], $city->{buildings}->{warehouse})); | 65 |
66 Carp::carp(sprintf("Required warehouse level %s for %s cities, current is %s\n", $warehouse[$citiesNumber], $citiesNumber, $city->{buildings}->{warehouse})); | |
66 return 0 if(!defined($city->{buildings}->{warehouse})); | 67 return 0 if(!defined($city->{buildings}->{warehouse})); |
67 return ($city->{buildings}->{warehouse} >= $warehouse[$#cities]) ? 1 : 0; | 68 return ($city->{buildings}->{warehouse} >= $warehouse[$citiesNumber]) ? 1 : 0; |
68 } | 69 } |
69 | 70 |
70 sub is_corruption { | 71 sub is_corruption { |
71 my ($self, $city) = @_; | 72 my ($self, $city) = @_; |
72 return ($city->{corruption} > 0) ? 1 : 0; | 73 return ($city->{corruption} > 0) ? 1 : 0; |