Mercurial > eagle-eye
comparison 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 |
comparison
equal
deleted
inserted
replaced
196:ad88b3c92383 | 197:dbdd7dcc91c6 |
---|---|
45 return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*6)) ? 0 : 1) | 45 return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*6)) ? 0 : 1) |
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 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 | 52 |
53 return ($city->{buildings}->{warehouse} < $warehouse[$#cities]) ? 0 : 1; | 53 Carp::carp(sprintf("Required warehouse level %s, current is %s only\n", $warehouse[$#cities], $city->{buildings}->{warehouse})); |
54 return ($city->{buildings}->{warehouse} > $warehouse[$#cities]) ? 0 : 1; | |
54 } | 55 } |
55 | 56 |
56 sub is_corruption { | 57 sub is_corruption { |
57 my ($self, $city) = @_; | 58 my ($self, $city) = @_; |
58 return $city->{corruption}; | 59 return $city->{corruption}; |
234 } | 235 } |
235 } | 236 } |
236 | 237 |
237 sub is_barracks_upgrading { | 238 sub is_barracks_upgrading { |
238 my ($self, $city) = @_; | 239 my ($self, $city) = @_; |
239 return $::i->is_barracks_upgrading($city->{id}); | 240 return $self->{ikariam}->is_barracks_upgrading($city->{id}); |
240 } | 241 } |
241 | 242 |
242 sub is_army_trainning { | 243 sub is_army_trainning { |
243 my ($self, $city) = @_; | 244 my ($self, $city) = @_; |
244 return $self->{ikariam}->is_army_trainning($city->{id}); | 245 return $self->{ikariam}->is_army_trainning($city->{id}); |
261 } | 262 } |
262 | 263 |
263 # navy | 264 # navy |
264 sub is_navyExpenditure_available | 265 sub is_navyExpenditure_available |
265 { | 266 { |
266 my ($self, $cityId) = @_; | 267 my ($self, $city) = @_; |
268 my $cityId = $city->{id}; | |
267 | 269 |
268 # move this to somewhere else. | 270 # move this to somewhere else. |
269 my $workersRatio = { | 271 my $workersRatio = { |
270 'citizens' => 0.4, | 272 'citizens' => 0.4, |
271 'specialworkers' => 0.3, | 273 'specialworkers' => 0.3, |
288 } | 290 } |
289 | 291 |
290 # army | 292 # army |
291 sub is_milityExpenditure_available | 293 sub is_milityExpenditure_available |
292 { | 294 { |
293 my ($self, $cityId) = @_; | 295 my ($self, $city) = @_; |
296 my $cityId = $city->{id}; | |
297 | |
294 # move this to somewhere else. | 298 # move this to somewhere else. |
295 my $workersRatio = { | 299 my $workersRatio = { |
296 'citizens' => 0.4, | 300 'citizens' => 0.4, |
297 'specialworkers' => 0.3, | 301 'specialworkers' => 0.3, |
298 'woodworkers' => 0.7, | 302 'woodworkers' => 0.7, |
356 if (my $action = ParseTree($tree, $rules, $cities->{$cityId})) { | 360 if (my $action = ParseTree($tree, $rules, $cities->{$cityId})) { |
357 triggerAction($action, $cityId); | 361 triggerAction($action, $cityId); |
358 } | 362 } |
359 DumpFile("army-dump.yaml", $cities); | 363 DumpFile("army-dump.yaml", $cities); |
360 | 364 |
361 | |
362 # build and upgrade for cities | 365 # build and upgrade for cities |
363 $tree = LoadFile('city.yaml'); | 366 $tree = LoadFile('city.yaml'); |
364 $cities->{$cityId}->{parse_path} = []; | 367 $cities->{$cityId}->{parse_path} = []; |
365 $cities->{$cityId}->{parse_answer} = undef; | 368 $cities->{$cityId}->{parse_answer} = undef; |
366 if (my $action = ParseTree($tree, $rules, $cities->{$cityId})) { | 369 if (my $action = ParseTree($tree, $rules, $cities->{$cityId})) { |