Mercurial > eagle-eye
comparison agent.pl @ 234:b7ea7c43dbad
merged.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 06 Nov 2008 20:34:27 +0800 |
parents | afd3f5cb8597 978a949602e5 |
children | cf08e01f5713 |
comparison
equal
deleted
inserted
replaced
233:afd3f5cb8597 | 234:b7ea7c43dbad |
---|---|
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/); |
106 | 115 |
107 sub is_happiness { | 116 sub is_happiness { |
108 my ($self, $city) = @_; | 117 my ($self, $city) = @_; |
109 | 118 |
110 return ($city->{growth} >= 5 ? 1 : 0) | 119 return ($city->{growth} >= 5 ? 1 : 0) |
111 if($city->{buildings}->{townHall} <= 10); | 120 if($city->{buildings}->{townHall} <= 16); |
112 | 121 |
113 return 1 if($city->{buildings}->{townHall} >= 20); | 122 return 1 if($city->{buildings}->{townHall} >= 20); |
114 | 123 |
115 return ($city->{happiness} >= 2 ? 1 : 0); | 124 return ($city->{happiness} >= 2 ? 1 : 0); |
116 } | 125 } |
378 # maybe this should be moved to Rules. | 387 # maybe this should be moved to Rules. |
379 $i->blanceHurmanResource($cityId); | 388 $i->blanceHurmanResource($cityId); |
380 | 389 |
381 # build spy | 390 # build spy |
382 $i->buildSpy('spy', $cityId); | 391 $i->buildSpy('spy', $cityId); |
392 # enlarge the scientist number. | |
393 $i->set("academy", $cityId); | |
394 $i->set("tavern", $cityId); | |
383 | 395 |
384 # build military! | 396 # build military! |
385 $tree = LoadFile('military.yaml'); | 397 $tree = LoadFile('military.yaml'); |
386 $cities->{$cityId}->{parse_path} = []; | 398 $cities->{$cityId}->{parse_path} = []; |
387 $cities->{$cityId}->{parse_answer} = undef; | 399 $cities->{$cityId}->{parse_answer} = undef; |