diff agent.pl @ 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 dbdd7dcc91c6
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 {