comparison agent.pl @ 245:a344c54f15c7

merge work
author hychen@mluna
date Thu, 23 Oct 2008 00:47:56 +0800
parents 2af91e80353e
children 27b16506231f
comparison
equal deleted inserted replaced
73:c20912354d1d 245:a344c54f15c7
14 my ( $class ) = @_; 14 my ( $class ) = @_;
15 my $self = {}; 15 my $self = {};
16 return bless $self, $class; 16 return bless $self, $class;
17 } 17 }
18 18
19 sub is_Attacked { 19 sub is_attacked {
20 my ($self, $city) = @_; 20 my ($self, $city) = @_;
21 return ($city->{force}->{attacks} > 0 ) ? 1 : 0; 21 return ($city->{force}->{attacks} > 0 ) ? 1 : 0;
22 } 22 }
23 23
24 sub is_constructing { 24 sub is_constructing {
33 } 33 }
34 34
35 sub is_space_enough { 35 sub is_space_enough {
36 my ($self, $city) = @_; 36 my ($self, $city) = @_;
37 # TODO 應該以消耗率/時間計算 37 # TODO 應該以消耗率/時間計算
38 return ($city->{space}->{total} <= ($city->{space}->{occupied}+6) ? 1 : 0) 38 return ($city->{space}->{total} <= ($city->{space}->{occupied}+6) ? 0 : 1)
39 } 39 }
40 40
41 sub is_corruption { 41 sub is_corruption {
42 my ($self, $city) = @_; 42 my ($self, $city) = @_;
43 return 0; 43 return 0;
47 my ($self, $city) = @_; 47 my ($self, $city) = @_;
48 # TODO 以 fuzzy 取出合理 happiness 值 48 # TODO 以 fuzzy 取出合理 happiness 值
49 return ($city->{happiness} >= 2 ? 1 : 0) 49 return ($city->{happiness} >= 2 ? 1 : 0)
50 } 50 }
51 51
52 sub is_warehouse_enough 52 sub is_warehouse_enough {
53 {
54 my ($self, $city) = @_; 53 my ($self, $city) = @_;
55 # TODO 以速率計算容納率 54 # TODO 以速率計算容納率
56 # XXX: not implemented yet. 55 # XXX: not implemented yet.
57 return 1; 56 return 1;
58 } 57 }
59 58
60 sub is_risk 59 sub is_risk {
61 {
62 my ($self, $city) = @_; 60 my ($self, $city) = @_;
63 # TODO 計算可搶劫比例, 城牆防護, 軍事分數 61 # TODO 計算可搶劫比例, 城牆防護, 軍事分數
64 return 0; 62 return 0;
65 }
66
67 sub is_shipyard
68 {
69 return 1;
70 } 63 }
71 64
72 sub is_gold_enoughforcargo { 65 sub is_gold_enoughforcargo {
73 my ($self, $city) = @_; 66 my ($self, $city) = @_;
74 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/; 67 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/;
119 } 112 }
120 113
121 sub is_winepress_researched { 114 sub is_winepress_researched {
122 my ($self, $city) = @_; 115 my ($self, $city) = @_;
123 return (defined($city->{research}->{2040}) ? 1 : 0); 116 return (defined($city->{research}->{2040}) ? 1 : 0);
117 }
118
119 sub is_invention_researched {
120 my ($self, $city) = @_;
121 return (defined($city->{research}->{3040}) ? 1 : 0);
122 }
123
124 sub is_barracks_level_enough {
125 my ($self, $city) = @_;
126 return 0 if(!defined($city->{building}->{barracks}));
127 return ($city->{building}->{barracks} >= 3 ? 1 : 0);
128 }
129
130 sub is_shipyard_level_enough {
131 my ($self, $city) = @_;
132 return 0 if(!defined($city->{building}->{shipyard}));
133 return ($city->{building}->{shipyard} >= 2 ? 1 : 0);
134 return 0;
124 } 135 }
125 136
126 sub rule_engagement 137 sub rule_engagement
127 { 138 {
128 my ($self, $city) = @_; 139 my ($self, $city) = @_;
175 } else { 186 } else {
176 187
177 } 188 }
178 } 189 }
179 # Debug 190 # Debug
180 print(Dumper($cities->{$cityId}->{parse_path})); 191 # print(Dumper($cities->{$cityId}->{parse_path}));
181 } 192 }
182 193
183 $i->logout; 194 $i->logout;
184 195
185 196