diff agent.pl @ 67:6eccb3a95df5

refiended the research of tech tree, and added many todos
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Wed, 22 Oct 2008 06:24:01 +0800
parents b40f87f16263
children 2af91e80353e
line wrap: on
line diff
--- a/agent.pl	Tue Oct 21 16:41:30 2008 +0800
+++ b/agent.pl	Wed Oct 22 06:24:01 2008 +0800
@@ -16,7 +16,7 @@
     return bless $self, $class;
 }
 
-sub is_Attacked {
+sub is_attacked {
     my ($self, $city) = @_;
     return ($city->{force}->{attacks} > 0 ) ? 1 : 0;
 }
@@ -123,6 +123,25 @@
     return (defined($city->{research}->{2040}) ?  1 : 0);
 }
 
+sub is_invention_researched {
+    my ($self, $city) = @_;
+    return (defined($city->{research}->{3040}) ?  1 : 0);
+}
+
+sub is_barracks_level_enough {
+    my ($self, $city) = @_;
+    return 0 if(!defined($city->{building}->{barracks}));
+    return ($city->{building}->{barracks} >= 3 ? 1 : 0);
+    return 0;
+}
+
+sub is_shipyard_level_enough {
+    my ($self, $city) = @_;
+    return 0 if(!defined($city->{building}->{shipyard}));
+    return ($city->{building}->{shipyard} >= 2 ? 1 : 0);
+    return 0;
+}
+
 sub rule_engagement
 {
     my ($self, $city) = @_;
@@ -177,7 +196,7 @@
         }
     }
     # Debug
-    print(Dumper($cities->{$cityId}->{parse_path}));
+    # print(Dumper($cities->{$cityId}->{parse_path}));
 }
 
 $i->logout;