# HG changeset patch # User "Rex Tsai " # Date 1224517485 -28800 # Node ID ff00d108e955f4778d51c265313be9d312563876 # Parent 2d3c394b7940b0044f6014ab67a257b847df90cb check resources for build_townHall diff -r 2d3c394b7940 -r ff00d108e955 agent.pl --- a/agent.pl Mon Oct 20 23:24:15 2008 +0800 +++ b/agent.pl Mon Oct 20 23:44:45 2008 +0800 @@ -81,6 +81,19 @@ } } +sub is_resource_enoghforHall { + my ($self, $city) = @_; + 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/; + 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/; + + my $level = $city->{buildings}->{townHall}; + if($city->{resources}->{woold} >= $wood[$level] && $city->{resources}->{marble} >= $marble[$level] ) { + return 1; + } + warn("Resource is short for build city hall."); + return 0; +} + sub is_drydock_researched { my ($self, $city) = @_; return (defined($city->{research}->{4010}) ? 1 : 0); @@ -138,7 +151,11 @@ { # TODO: remove the last rule, if the result is fallback triggerAction($action, $cityId); - last; + if($cities->{$cityId}->{parse_answer} ne "fallback") { + last ; + } else { + + } } # Debug print(Dumper($cities->{$cityId}->{parse_path})); diff -r 2d3c394b7940 -r ff00d108e955 building.yaml --- a/building.yaml Mon Oct 20 23:24:15 2008 +0800 +++ b/building.yaml Mon Oct 20 23:44:45 2008 +0800 @@ -16,7 +16,9 @@ - is_wall_enough: 0: build_wall - is_space_enough: - 0: build_townHall + 0: + - is_resource_enoghforHall: + 1: build_townHall - is_corruption: 1: build_governorsresidence # 倉庫庫存量