diff agent.pl @ 137:362184763c04

added comments and added new research (greek fire)
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Fri, 31 Oct 2008 02:21:05 +0800
parents 73f0a1cafc23
children 3bbb1e559e21
line wrap: on
line diff
--- a/agent.pl	Fri Oct 31 00:20:41 2008 +0800
+++ b/agent.pl	Fri Oct 31 02:21:05 2008 +0800
@@ -37,10 +37,11 @@
 
 sub is_space_enough {
     my ($self, $city) = @_;
-    # TODO 應該以消耗率/時間計算
-    # $self->{ikariam}->{growth}
+    # The maximum town hall is level 20, then we build new town
     return 1 if($city->{buildings}->{townHall} >= 20);
-    return ($city->{space}->{total} <= ($city->{space}->{occupied}+6) ?  0 : 1)
+    # TODO 應該以 成長率 * 升級所需時間計算
+    # 6 hours earlier, we upgrade the twonHall.
+    return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*6)) ?  0 : 1)
 }
 
 sub is_corruption {
@@ -51,7 +52,16 @@
 sub is_happiness {
     my ($self, $city) = @_;
     # TODO 以 fuzzy 取出合理 happiness 值
-    return ($city->{happiness} >= 2 ?  1 : 0)
+
+    # we should update the travl
+    # return ($city->{growth} >= 5 ?  1 : 0) 
+    #    if($city->{buildings}->{townHall} <= 10);
+
+    return 0;
+ 
+    # FIXME.
+    # we should update the tavern setting.
+    # return ($city->{happiness} >= 2 ?  1 : 0);
 }
 
 sub is_warehouse_enough {
@@ -66,7 +76,6 @@
     # 
     # my $capture = $city->{buildings}->{townHall} * ($city->{buildings}->{townHall} - 1) * $city->{resource}->gold / 10000;
     # 計算軍人消耗
-    #
     # 方陣兵, 1.58 軍分, 24 維護費
     # 劍士, 4.64 軍分, 16 維護費
     # army_score_main > (occupied * 0.3)
@@ -143,6 +152,11 @@
     return (defined($self->{'ikariam'}->{research}->{4010}) ?  1 : 0);
 }
 
+sub is_greekfire_researched {
+    my ($self) = @_;
+    return (defined($self->{'ikariam'}->{research}->{6077}) ?  1 : 0);
+}
+
 sub is_barracks_level_enough {
     my ($self, $city) = @_;
     return 0 if(!defined($city->{buildings}->{barracks}));
@@ -226,6 +240,7 @@
 
 our $i = new Ikariam($::server, $::user, $::pass);
 $i->login;
+$i->checkMilitaryAdvisorCombatReports();
 my $cities = $i->check;
 
 # Genereic rules for both overall and city level arranagement.
@@ -237,7 +252,7 @@
 $decision->{parse_answer} = undef;
 my $action = ParseTree($tree, $rules, $decision);
 triggerAction($action, (keys(%$cities))[0]) if(defined($action));
-print STDERR Dump($decision) if(defined($verbose));
+# print STDERR Dump($decision) if(defined($verbose));
 
 # show cities.
 foreach my $cityId (keys(%$cities)) {