diff agent.pl @ 199:b33c8dbe9b04

fixed is_any_corruption
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Mon, 03 Nov 2008 12:00:54 +0800
parents 2dfeb4371db7
children eec013e81fb0
line wrap: on
line diff
--- a/agent.pl	Mon Nov 03 11:42:59 2008 +0800
+++ b/agent.pl	Mon Nov 03 12:00:54 2008 +0800
@@ -51,6 +51,7 @@
     my @cities = keys(%{$self->{ikariam}->{cities}});
 
     Carp::carp(sprintf("Required warehouse level %s, current is %s only\n", $warehouse[$#cities], $city->{buildings}->{warehouse}));
+    return 0 if(!defined($city->{buildings}->{warehouse}));
     return ($city->{buildings}->{warehouse} > $warehouse[$#cities]) ? 0 : 1;
 }
 
@@ -63,7 +64,7 @@
     my ($self, $city) = @_;
 
     foreach (keys(%{$self->{ikariam}->{cities}})) {
-        return ($self->{ikariam}->{cities}->{$_}->{corruption} > 0) ? 1 : 0;
+        return 1 if ($self->{ikariam}->{cities}->{$_}->{corruption} > 0);
     }
     return 0;
 }