comparison agent.pl @ 55:ff00d108e955

check resources for build_townHall
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Mon, 20 Oct 2008 23:44:45 +0800
parents 2d3c394b7940
children 6e0d5e781949
comparison
equal deleted inserted replaced
54:2d3c394b7940 55:ff00d108e955
79 } else { 79 } else {
80 return 0; 80 return 0;
81 } 81 }
82 } 82 }
83 83
84 sub is_resource_enoghforHall {
85 my ($self, $city) = @_;
86 my @wood = qw/udnef 0 70 98 65 129 236 402 594 849 1176 1586 2101 3208 4937 7171 10139 14537 18420 22896 28047 33934 40623 48017 56511 226044 452088 904176 1808352 3616704 7233408 14466816 28933632/;
87 my @marble = qw/undef 0 0 17 28 66 95 156 243 406 579 799 1348 2124 2951 4409 6461 8187 10176 12466 15082 18055 21381 25116 100464 200928 401856 803712 1607424 3214848 6429696 12859392/;
88
89 my $level = $city->{buildings}->{townHall};
90 if($city->{resources}->{woold} >= $wood[$level] && $city->{resources}->{marble} >= $marble[$level] ) {
91 return 1;
92 }
93 warn("Resource is short for build city hall.");
94 return 0;
95 }
96
84 sub is_drydock_researched { 97 sub is_drydock_researched {
85 my ($self, $city) = @_; 98 my ($self, $city) = @_;
86 return (defined($city->{research}->{4010}) ? 1 : 0); 99 return (defined($city->{research}->{4010}) ? 1 : 0);
87 } 100 }
88 101
136 $cities->{$cityId}->{parse_answer} = undef; 149 $cities->{$cityId}->{parse_answer} = undef;
137 while (my $action = ParseTree($tree, $rules, $cities->{$cityId})) 150 while (my $action = ParseTree($tree, $rules, $cities->{$cityId}))
138 { 151 {
139 # TODO: remove the last rule, if the result is fallback 152 # TODO: remove the last rule, if the result is fallback
140 triggerAction($action, $cityId); 153 triggerAction($action, $cityId);
141 last; 154 if($cities->{$cityId}->{parse_answer} ne "fallback") {
155 last ;
156 } else {
157
158 }
142 } 159 }
143 # Debug 160 # Debug
144 print(Dumper($cities->{$cityId}->{parse_path})); 161 print(Dumper($cities->{$cityId}->{parse_path}));
145 } 162 }
146 163