changeset 193:a6a4a48d5fda

we don't bulid anything, untill we fix corruption
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 02 Nov 2008 23:51:41 +0800
parents d6dc50b64f06
children 015ac84d038c 1332231eb5a0
files agent.pl city.yaml
diffstat 2 files changed, 42 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/agent.pl	Sun Nov 02 23:39:49 2008 +0800
+++ b/agent.pl	Sun Nov 02 23:51:41 2008 +0800
@@ -48,7 +48,7 @@
 sub is_warehouse_enougn_for_governorsresidence {
     my ($self, $city) = @_;
     my @warehouse = (qw/undef 0 4 9 16 18 19 20 21 22 23 24 25/);
-    my @cities = keys(%{$::i->{cities}});
+    my @cities = keys(%{$self->{ikariam}->{cities}});
 
     return ($city->{buildings}->{warehouse} < $warehouse[$#cities]) ? 0 : 1;
 }
@@ -58,6 +58,15 @@
     return $city->{corruption};
 }
 
+sub is_any_corruption {
+    my ($self, $city) = @_;
+
+    foreach (keys(%{$self->{ikariam}->{cities}})) {
+        return 1 if($self->{ikariam}->{cities}->{$_}->{corruption} == 1);
+    }
+    return 0;
+}
+
 sub is_happiness {
     my ($self, $city) = @_;
 
@@ -201,12 +210,12 @@
 
 sub is_shipyard_upgrading {
     my ($self, $city) = @_;
-    return $::i->is_shipyard_upgrading($city->{id});
+    return $self->{'ikariam'}->is_shipyard_upgrading($city->{id});
 }
 
 sub is_navy_trainning {
     my ($self, $city) = @_;
-    return $::i->is_navy_trainning($city->{id});
+    return $self->{'ikariam'}->is_navy_trainning($city->{id});
 }
 
 sub train_navy {
@@ -232,7 +241,7 @@
 
 sub is_army_trainning {
     my ($self, $city) = @_;
-    return $::i->is_army_trainning($city->{id});
+    return $self->{ikariam}->is_army_trainning($city->{id});
 }
 
 sub train_army {
--- a/city.yaml	Sun Nov 02 23:39:49 2008 +0800
+++ b/city.yaml	Sun Nov 02 23:51:41 2008 +0800
@@ -16,41 +16,39 @@
                   - is_warehouse_enougn_for_governorsresidence:
                      0: build_warehouse
                      1: build_governorsresidence
-            - is_space_enough:
+            - is_any_corruption:
                0: 
-                  - is_resource_enoghforHall:
-                     1: build_townHall
-            - is_wall_enough:
-               0: build_wall
-            # 倉庫庫存量
-            - is_warehouse_enough:
-               0: build_warehouse
-            - is_happiness:
-               0:
-                  - is_winepress_researched:
+                  - is_space_enough:
+                     0: 
+                        - is_resource_enoghforHall:
+                           1: build_townHall
+                  - is_wall_enough:
+                     0: build_wall
+                  # 倉庫庫存量
+                  - is_warehouse_enough:
+                     0: build_warehouse
+                  - is_happiness:
+                     0:
+                        - is_winepress_researched:
+                           1:
+                              - is_tavern_available:
+                                 0: build_tavern
+                                 1: 
+                                    - is_bacchanal:
+                                       0: set_tavern
+                                       1: build_tavern
+                  - is_navyExpenditure_available:
                      1:
-                        - is_tavern_available:
-                           0: build_tavern
-                           1: 
-                              - is_bacchanal:
-                                 0: set_tavern
-                                 1: build_tavern
-            - is_navyExpenditure_available:
-               1:
-                  - is_professionalarmy_researched:
+                        - is_professionalarmy_researched:
+                           1:
+                              - is_shipyard_level_enough:
+                                 0: build_shipyard
+                  - is_milityExpenditure_available:
                      1:
-                        - is_shipyard_level_enough:
-                           0: build_shipyard
-                           1: 
-                              - train_navy:
-            - is_milityExpenditure_available:
-               1:
-                  - is_professionalarmy_researched:
-                     1:
-                        - is_barracks_level_enough:
-                           0: build_barracks
+                        - is_professionalarmy_researched:
                            1:
-                              - train_army:
+                              - is_barracks_level_enough:
+                                 0: build_barracks
             # TODO
             # build_safehouse
             # is_espionage_researched