comparison agent.pl @ 206:b7af307a222d

added build safehouse
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Mon, 03 Nov 2008 17:52:28 +0800
parents 60f4ce7e1f63
children 48ea8222782a
comparison
equal deleted inserted replaced
205:d9f17bcbf1f1 206:b7af307a222d
41 # The maximum town hall is level 20, then we build new town 41 # The maximum town hall is level 20, then we build new town
42 return 1 if($city->{buildings}->{townHall} >= 20); 42 return 1 if($city->{buildings}->{townHall} >= 20);
43 # TODO 應該以 成長率 * 升級所需時間計算 43 # TODO 應該以 成長率 * 升級所需時間計算
44 # 6 hours earlier, we upgrade the twonHall. 44 # 6 hours earlier, we upgrade the twonHall.
45 return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*8)) ? 0 : 1) 45 return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*8)) ? 0 : 1)
46 }
47
48 sub is_safehouse_enough {
49 my ($self, $city) = @_;
50 return 0 if(!defined($city->{building}->{safehouse}));
51 return (($city->{building}->{townHall} <= ($city->{building}->{safehouse} + 4)) ? 0 : 1);
46 } 52 }
47 53
48 sub is_warehouse_enough { 54 sub is_warehouse_enough {
49 my ($self, $city) = @_; 55 my ($self, $city) = @_;
50 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); 56 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);