Mercurial > eagle-eye
comparison agent.pl @ 232:978a949602e5
Auto-update Scientists numbers for Academy.
Refined the rules for safehouse, the safe house must be same or higher level then Town Hall.
Make people very happy, when the townHall is less then 16.
Build museum first then tavern
THG: changed warfare.pl
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 06 Nov 2008 20:31:05 +0800 |
parents | f6836ef11203 |
children | b7ea7c43dbad |
comparison
equal
deleted
inserted
replaced
231:c0b9604b0be9 | 232:978a949602e5 |
---|---|
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/); |
105 | 114 |
106 sub is_happiness { | 115 sub is_happiness { |
107 my ($self, $city) = @_; | 116 my ($self, $city) = @_; |
108 | 117 |
109 return ($city->{growth} >= 5 ? 1 : 0) | 118 return ($city->{growth} >= 5 ? 1 : 0) |
110 if($city->{buildings}->{townHall} <= 10); | 119 if($city->{buildings}->{townHall} <= 16); |
111 | 120 |
112 return 1 if($city->{buildings}->{townHall} >= 20); | 121 return 1 if($city->{buildings}->{townHall} >= 20); |
113 | 122 |
114 return ($city->{happiness} >= 2 ? 1 : 0); | 123 return ($city->{happiness} >= 2 ? 1 : 0); |
115 } | 124 } |
377 # maybe this should be moved to Rules. | 386 # maybe this should be moved to Rules. |
378 $i->blanceHurmanResource($cityId); | 387 $i->blanceHurmanResource($cityId); |
379 | 388 |
380 # build spy | 389 # build spy |
381 $i->buildSpy('spy', $cityId); | 390 $i->buildSpy('spy', $cityId); |
391 # enlarge the scientist number. | |
392 $i->set("academy", $cityId); | |
393 $i->set("tavern", $cityId); | |
382 | 394 |
383 # build military! | 395 # build military! |
384 $tree = LoadFile('military.yaml'); | 396 $tree = LoadFile('military.yaml'); |
385 $cities->{$cityId}->{parse_path} = []; | 397 $cities->{$cityId}->{parse_path} = []; |
386 $cities->{$cityId}->{parse_answer} = undef; | 398 $cities->{$cityId}->{parse_answer} = undef; |