Mercurial > eagle-eye
diff agent.pl @ 245:a344c54f15c7
merge work
author | hychen@mluna |
---|---|
date | Thu, 23 Oct 2008 00:47:56 +0800 |
parents | 2af91e80353e |
children | 27b16506231f |
line wrap: on
line diff
--- a/agent.pl Thu Oct 23 00:33:22 2008 +0800 +++ b/agent.pl Thu Oct 23 00:47:56 2008 +0800 @@ -16,7 +16,7 @@ return bless $self, $class; } -sub is_Attacked { +sub is_attacked { my ($self, $city) = @_; return ($city->{force}->{attacks} > 0 ) ? 1 : 0; } @@ -35,7 +35,7 @@ sub is_space_enough { my ($self, $city) = @_; # TODO 應該以消耗率/時間計算 - return ($city->{space}->{total} <= ($city->{space}->{occupied}+6) ? 1 : 0) + return ($city->{space}->{total} <= ($city->{space}->{occupied}+6) ? 0 : 1) } sub is_corruption { @@ -49,26 +49,19 @@ return ($city->{happiness} >= 2 ? 1 : 0) } -sub is_warehouse_enough -{ +sub is_warehouse_enough { my ($self, $city) = @_; # TODO 以速率計算容納率 # XXX: not implemented yet. return 1; } -sub is_risk -{ +sub is_risk { my ($self, $city) = @_; # TODO 計算可搶劫比例, 城牆防護, 軍事分數 return 0; } -sub is_shipyard -{ - return 1; -} - sub is_gold_enoughforcargo { my ($self, $city) = @_; 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/; @@ -123,6 +116,24 @@ return (defined($city->{research}->{2040}) ? 1 : 0); } +sub is_invention_researched { + my ($self, $city) = @_; + return (defined($city->{research}->{3040}) ? 1 : 0); +} + +sub is_barracks_level_enough { + my ($self, $city) = @_; + return 0 if(!defined($city->{building}->{barracks})); + return ($city->{building}->{barracks} >= 3 ? 1 : 0); +} + +sub is_shipyard_level_enough { + my ($self, $city) = @_; + return 0 if(!defined($city->{building}->{shipyard})); + return ($city->{building}->{shipyard} >= 2 ? 1 : 0); + return 0; +} + sub rule_engagement { my ($self, $city) = @_; @@ -177,7 +188,7 @@ } } # Debug - print(Dumper($cities->{$cityId}->{parse_path})); + # print(Dumper($cities->{$cityId}->{parse_path})); } $i->logout;