changeset 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 285d5b39ef2c
children 6bce423892f4
files agent.pl
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/agent.pl	Tue Nov 25 23:46:42 2008 +0800
+++ b/agent.pl	Sat Nov 29 02:16:35 2008 +0800
@@ -39,6 +39,7 @@
 sub is_academy_enough {
     my ($self, $city) = @_;
     return ($city->{buildings}->{academy} >= 6 ?  1 : 0);
+    return ($city->{buildings}->{academy} >= 16 ?  1 : 0);
 }
 
 sub is_embassy_enough {
@@ -48,6 +49,7 @@
 
 sub is_museum_enough {
     my ($self, $city) = @_;
+    return 1 if($city->{buildings}->{museum} >= 8);
     return ($city->{buildings}->{museum} >= ($city->{buildings}->{tavern}/2) ? 1 : 0);
 }
 
@@ -68,22 +70,21 @@
 sub is_safehouse_enough {
     my ($self, $city) = @_;
     return 0 if(!defined($city->{buildings}->{safehouse}));
+    return 1 if($$city->{buildings}->{townHall} >= 20);
 
     # build the higgest safehouse.
     # maybe we should have more then 4 towns, then we consider that we should upgrade safehouse at level 20.
     # return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1) 
-        # if($$city->{buildings}->{townHall} >= 20);
     # return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1);
 
     # Safehouse must be same level as townHall,
-    # Maybe one level higher is better.
-    return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1);
+    return (($city->{buildings}->{townHall} >= $city->{buildings}->{safehouse}) ? 0 : 1);
 }
 
 sub is_warehouse_enough {
     my ($self, $city) = @_;
     # my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);
-    my @warehouse = (qw/undef undef 0 4 9 15 18 19 20 21 22 23 24 25/);
+    my @warehouse = (qw/undef undef 0 4 9 15 17 19 20 21 22 23 24 25/);
     my @cities = keys(%{$self->{ikariam}->{cities}});
     my $nextCities = ($#cities + 1) + 1;
 
@@ -396,6 +397,8 @@
     $i->buildSpy('spy', $cityId);
     # enlarge the scientist number.
     $i->set("academy", $cityId);
+
+    # Only when you are not happy.
     $i->set("tavern", $cityId);
 
     # build military!