comparison agent.pl @ 193:a6a4a48d5fda

we don't bulid anything, untill we fix corruption
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 02 Nov 2008 23:51:41 +0800
parents d6dc50b64f06
children dbdd7dcc91c6
comparison
equal deleted inserted replaced
192:d6dc50b64f06 193:a6a4a48d5fda
46 } 46 }
47 47
48 sub is_warehouse_enougn_for_governorsresidence { 48 sub is_warehouse_enougn_for_governorsresidence {
49 my ($self, $city) = @_; 49 my ($self, $city) = @_;
50 my @warehouse = (qw/undef 0 4 9 16 18 19 20 21 22 23 24 25/); 50 my @warehouse = (qw/undef 0 4 9 16 18 19 20 21 22 23 24 25/);
51 my @cities = keys(%{$::i->{cities}}); 51 my @cities = keys(%{$self->{ikariam}->{cities}});
52 52
53 return ($city->{buildings}->{warehouse} < $warehouse[$#cities]) ? 0 : 1; 53 return ($city->{buildings}->{warehouse} < $warehouse[$#cities]) ? 0 : 1;
54 } 54 }
55 55
56 sub is_corruption { 56 sub is_corruption {
57 my ($self, $city) = @_; 57 my ($self, $city) = @_;
58 return $city->{corruption}; 58 return $city->{corruption};
59 }
60
61 sub is_any_corruption {
62 my ($self, $city) = @_;
63
64 foreach (keys(%{$self->{ikariam}->{cities}})) {
65 return 1 if($self->{ikariam}->{cities}->{$_}->{corruption} == 1);
66 }
67 return 0;
59 } 68 }
60 69
61 sub is_happiness { 70 sub is_happiness {
62 my ($self, $city) = @_; 71 my ($self, $city) = @_;
63 72
199 # TODO 208 # TODO
200 } 209 }
201 210
202 sub is_shipyard_upgrading { 211 sub is_shipyard_upgrading {
203 my ($self, $city) = @_; 212 my ($self, $city) = @_;
204 return $::i->is_shipyard_upgrading($city->{id}); 213 return $self->{'ikariam'}->is_shipyard_upgrading($city->{id});
205 } 214 }
206 215
207 sub is_navy_trainning { 216 sub is_navy_trainning {
208 my ($self, $city) = @_; 217 my ($self, $city) = @_;
209 return $::i->is_navy_trainning($city->{id}); 218 return $self->{'ikariam'}->is_navy_trainning($city->{id});
210 } 219 }
211 220
212 sub train_navy { 221 sub train_navy {
213 my ($self, $city) = @_; 222 my ($self, $city) = @_;
214 my $cityId = $city->{id}; 223 my $cityId = $city->{id};
230 return $::i->is_barracks_upgrading($city->{id}); 239 return $::i->is_barracks_upgrading($city->{id});
231 } 240 }
232 241
233 sub is_army_trainning { 242 sub is_army_trainning {
234 my ($self, $city) = @_; 243 my ($self, $city) = @_;
235 return $::i->is_army_trainning($city->{id}); 244 return $self->{ikariam}->is_army_trainning($city->{id});
236 } 245 }
237 246
238 sub train_army { 247 sub train_army {
239 my ($self, $city) = @_; 248 my ($self, $city) = @_;
240 my $cityId = $city->{id}; 249 my $cityId = $city->{id};