Mercurial > eagle-eye
comparison agent.pl @ 236:cf08e01f5713
merged.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 06 Nov 2008 20:36:24 +0800 |
parents | a89e049d1d31 b7ea7c43dbad |
children | a254fb798eb9 |
comparison
equal
deleted
inserted
replaced
235:a89e049d1d31 | 236:cf08e01f5713 |
---|---|
61 } | 61 } |
62 | 62 |
63 sub is_safehouse_enough { | 63 sub is_safehouse_enough { |
64 my ($self, $city) = @_; | 64 my ($self, $city) = @_; |
65 return 0 if(!defined($city->{buildings}->{safehouse})); | 65 return 0 if(!defined($city->{buildings}->{safehouse})); |
66 return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1); | 66 |
67 # build the higgest safehouse. | |
68 # maybe we should have more then 4 towns, then we consider that we should upgrade safehouse at level 20. | |
69 # return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1) | |
70 # if($$city->{buildings}->{townHall} >= 20); | |
71 # return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1); | |
72 | |
73 # Safehouse must be same level as townHall, | |
74 # Maybe one level higher is better. | |
75 return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1); | |
67 } | 76 } |
68 | 77 |
69 sub is_warehouse_enough { | 78 sub is_warehouse_enough { |
70 my ($self, $city) = @_; | 79 my ($self, $city) = @_; |
71 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); | 80 # my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); |
81 my @warehouse = (qw/undef undef 0 4 9 15 18 19 20 21 22 23 24 25/); | |
72 my @cities = keys(%{$self->{ikariam}->{cities}}); | 82 my @cities = keys(%{$self->{ikariam}->{cities}}); |
73 my $nextCities = ($#cities + 1) + 1; | 83 my $nextCities = ($#cities + 1) + 1; |
74 | 84 |
75 Carp::carp(sprintf("Required warehouse level %s for next city (%s), current is %s\n", $warehouse[$nextCities], $nextCities, $city->{buildings}->{warehouse})); | 85 Carp::carp(sprintf("Required warehouse level %s for next city (%s), current is %s\n", $warehouse[$nextCities], $nextCities, $city->{buildings}->{warehouse})); |
76 return 0 if(!defined($city->{buildings}->{warehouse})); | 86 return 0 if(!defined($city->{buildings}->{warehouse})); |
105 | 115 |
106 sub is_happiness { | 116 sub is_happiness { |
107 my ($self, $city) = @_; | 117 my ($self, $city) = @_; |
108 | 118 |
109 return ($city->{growth} >= 5 ? 1 : 0) | 119 return ($city->{growth} >= 5 ? 1 : 0) |
110 if($city->{buildings}->{townHall} <= 10); | 120 if($city->{buildings}->{townHall} <= 16); |
111 | 121 |
112 return 1 if($city->{buildings}->{townHall} >= 20); | 122 return 1 if($city->{buildings}->{townHall} >= 20); |
113 | 123 |
114 return ($city->{happiness} >= 2 ? 1 : 0); | 124 return ($city->{happiness} >= 2 ? 1 : 0); |
115 } | 125 } |
377 # maybe this should be moved to Rules. | 387 # maybe this should be moved to Rules. |
378 $i->blanceHurmanResource($cityId); | 388 $i->blanceHurmanResource($cityId); |
379 | 389 |
380 # build spy | 390 # build spy |
381 $i->buildSpy('spy', $cityId); | 391 $i->buildSpy('spy', $cityId); |
392 # enlarge the scientist number. | |
393 $i->set("academy", $cityId); | |
394 $i->set("tavern", $cityId); | |
382 | 395 |
383 # build military! | 396 # build military! |
384 $tree = LoadFile('military.yaml'); | 397 $tree = LoadFile('military.yaml'); |
385 $cities->{$cityId}->{parse_path} = []; | 398 $cities->{$cityId}->{parse_path} = []; |
386 $cities->{$cityId}->{parse_answer} = undef; | 399 $cities->{$cityId}->{parse_answer} = undef; |