comparison agent.pl @ 202:2c2dcbcc5c4d

upgrade warehouse for next city
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Mon, 03 Nov 2008 13:36:34 +0800
parents eec013e81fb0
children 60f4ce7e1f63
comparison
equal deleted inserted replaced
201:eec013e81fb0 202:2c2dcbcc5c4d
40 my ($self, $city) = @_; 40 my ($self, $city) = @_;
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}*6)) ? 0 : 1) 45 return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*8)) ? 0 : 1)
46 } 46 }
47
48 sub is_warehouse_enough {
49 my ($self, $city) = @_;
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}});
52 my $nextCities = $#cities + 1;
53
54 Carp::carp(sprintf("Required warehouse level %s, current is %s\n", $warehouse[$nextCities], $city->{buildings}->{warehouse}));
55 return 0 if(!defined($city->{buildings}->{warehouse}));
56 return ($city->{buildings}->{warehouse} >= $warehouse[$nextCities]) ? 1 : 0;
57 }
58
47 59
48 sub is_warehouse_enougn_for_governorsresidence { 60 sub is_warehouse_enougn_for_governorsresidence {
49 my ($self, $city) = @_; 61 my ($self, $city) = @_;
50 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); 62 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);
51 my @cities = keys(%{$self->{ikariam}->{cities}}); 63 my @cities = keys(%{$self->{ikariam}->{cities}});
86 } 98 }
87 99
88 sub is_bacchanal { 100 sub is_bacchanal {
89 my ($self, $city) = @_; 101 my ($self, $city) = @_;
90 return ($city->{tavern}->{maxValue} == $city->{tavern}->{iniValue} ? 1 : 0); 102 return ($city->{tavern}->{maxValue} == $city->{tavern}->{iniValue} ? 1 : 0);
91 }
92
93 sub is_warehouse_enough {
94 my ($self, $city) = @_;
95 # TODO 以速率計算容納率
96 return 1;
97 } 103 }
98 104
99 sub is_gold_enoughforcargo { 105 sub is_gold_enoughforcargo {
100 my ($self, $city) = @_; 106 my ($self, $city) = @_;
101 my @cargoCost = qw/160 244 396 812 1240 1272 1832 1888 3848 3972 5204 5384 6868 7120 8864 9200 11268 11712 14108 14680 23320 24288 28664 29880 34956 36468 42348 44212 51024 53308 61236 64024 73096 76468 87020 91088 103224 116524 122072 137432 180060 202132 211964 237444 249108 278276 292076 306623 321963 338138 355198 373191 392171 412195 433320 455612 479135 503962 530166 557828 587031 617863 650420 684802 721113 759466 799981 842783 888005 935790 986286 1039654 1096062 1155689 1218724 1285369 1355837 1430353 1509159 1592508 1680670 1773932 1872597 1976989 2087448 2204338 2328045 2458976 2597567 2744276 2899594 3064040 3238163 3422550 3617820 3824635 4043693 4275738 4521561 4782000 5057946 5350345 5660202 5988585 6336630 6705540 7096598 7511164 7950683 8416694 8910828 9434823 9990523 10579889 11205006 11868090 12571498 13317734 14109462 14949514/; 107 my @cargoCost = qw/160 244 396 812 1240 1272 1832 1888 3848 3972 5204 5384 6868 7120 8864 9200 11268 11712 14108 14680 23320 24288 28664 29880 34956 36468 42348 44212 51024 53308 61236 64024 73096 76468 87020 91088 103224 116524 122072 137432 180060 202132 211964 237444 249108 278276 292076 306623 321963 338138 355198 373191 392171 412195 433320 455612 479135 503962 530166 557828 587031 617863 650420 684802 721113 759466 799981 842783 888005 935790 986286 1039654 1096062 1155689 1218724 1285369 1355837 1430353 1509159 1592508 1680670 1773932 1872597 1976989 2087448 2204338 2328045 2458976 2597567 2744276 2899594 3064040 3238163 3422550 3617820 3824635 4043693 4275738 4521561 4782000 5057946 5350345 5660202 5988585 6336630 6705540 7096598 7511164 7950683 8416694 8910828 9434823 9990523 10579889 11205006 11868090 12571498 13317734 14109462 14949514/;