comparison agent.pl @ 269:c7f4a6f0fbde

added maxium level of buildings
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sat, 29 Nov 2008 02:16:35 +0800
parents 06ee88d2bb2a
children c1333052a4ed
comparison
equal deleted inserted replaced
268:285d5b39ef2c 269:c7f4a6f0fbde
37 } 37 }
38 38
39 sub is_academy_enough { 39 sub is_academy_enough {
40 my ($self, $city) = @_; 40 my ($self, $city) = @_;
41 return ($city->{buildings}->{academy} >= 6 ? 1 : 0); 41 return ($city->{buildings}->{academy} >= 6 ? 1 : 0);
42 return ($city->{buildings}->{academy} >= 16 ? 1 : 0);
42 } 43 }
43 44
44 sub is_embassy_enough { 45 sub is_embassy_enough {
45 my ($self, $city) = @_; 46 my ($self, $city) = @_;
46 return ($city->{buildings}->{embassy} >= 6 ? 1 : 0); 47 return ($city->{buildings}->{embassy} >= 6 ? 1 : 0);
47 } 48 }
48 49
49 sub is_museum_enough { 50 sub is_museum_enough {
50 my ($self, $city) = @_; 51 my ($self, $city) = @_;
52 return 1 if($city->{buildings}->{museum} >= 8);
51 return ($city->{buildings}->{museum} >= ($city->{buildings}->{tavern}/2) ? 1 : 0); 53 return ($city->{buildings}->{museum} >= ($city->{buildings}->{tavern}/2) ? 1 : 0);
52 } 54 }
53 55
54 sub is_branchOffice_enough { 56 sub is_branchOffice_enough {
55 my ($self, $city) = @_; 57 my ($self, $city) = @_;
66 } 68 }
67 69
68 sub is_safehouse_enough { 70 sub is_safehouse_enough {
69 my ($self, $city) = @_; 71 my ($self, $city) = @_;
70 return 0 if(!defined($city->{buildings}->{safehouse})); 72 return 0 if(!defined($city->{buildings}->{safehouse}));
73 return 1 if($$city->{buildings}->{townHall} >= 20);
71 74
72 # build the higgest safehouse. 75 # build the higgest safehouse.
73 # maybe we should have more then 4 towns, then we consider that we should upgrade safehouse at level 20. 76 # maybe we should have more then 4 towns, then we consider that we should upgrade safehouse at level 20.
74 # return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1) 77 # return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1)
75 # if($$city->{buildings}->{townHall} >= 20);
76 # return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1); 78 # return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1);
77 79
78 # Safehouse must be same level as townHall, 80 # Safehouse must be same level as townHall,
79 # Maybe one level higher is better. 81 return (($city->{buildings}->{townHall} >= $city->{buildings}->{safehouse}) ? 0 : 1);
80 return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1);
81 } 82 }
82 83
83 sub is_warehouse_enough { 84 sub is_warehouse_enough {
84 my ($self, $city) = @_; 85 my ($self, $city) = @_;
85 # my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/); 86 # my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);
86 my @warehouse = (qw/undef undef 0 4 9 15 18 19 20 21 22 23 24 25/); 87 my @warehouse = (qw/undef undef 0 4 9 15 17 19 20 21 22 23 24 25/);
87 my @cities = keys(%{$self->{ikariam}->{cities}}); 88 my @cities = keys(%{$self->{ikariam}->{cities}});
88 my $nextCities = ($#cities + 1) + 1; 89 my $nextCities = ($#cities + 1) + 1;
89 90
90 Carp::carp(sprintf("Required warehouse level %s for next city (%s), current is %s\n", $warehouse[$nextCities], $nextCities, $city->{buildings}->{warehouse})); 91 Carp::carp(sprintf("Required warehouse level %s for next city (%s), current is %s\n", $warehouse[$nextCities], $nextCities, $city->{buildings}->{warehouse}));
91 return 0 if(!defined($city->{buildings}->{warehouse})); 92 return 0 if(!defined($city->{buildings}->{warehouse}));
394 395
395 # build spy 396 # build spy
396 $i->buildSpy('spy', $cityId); 397 $i->buildSpy('spy', $cityId);
397 # enlarge the scientist number. 398 # enlarge the scientist number.
398 $i->set("academy", $cityId); 399 $i->set("academy", $cityId);
400
401 # Only when you are not happy.
399 $i->set("tavern", $cityId); 402 $i->set("tavern", $cityId);
400 403
401 # build military! 404 # build military!
402 $tree = LoadFile('military.yaml'); 405 $tree = LoadFile('military.yaml');
403 $cities->{$cityId}->{parse_path} = []; 406 $cities->{$cityId}->{parse_path} = [];