changeset 258:689c4c9fa56b

fixed loop
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Tue, 18 Nov 2008 02:28:45 +0800
parents 2d205c539688
children a4e52feec5a5
files warfare.pl
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/warfare.pl	Mon Nov 17 19:15:51 2008 +0800
+++ b/warfare.pl	Tue Nov 18 02:28:45 2008 +0800
@@ -106,10 +106,11 @@
         my $c = Ikariam::Report->search_victim($city->cityId, time - 24*60*60 - 7*60*60)->count();
         # check the current plunders
         foreach (@{$self->{ikariam}->{'military'}->{'homeland'}}) {
-            # we don't attack same city twice at same time.
-            next if($_->{to} == $city->cityId);
             # counting for both leaving and coming back.
             $c++ if($_->{to} == $city->cityId || $_->{from} == $city->cityId);
+
+            # we don't attack same city twice at same time.
+            next CITY if($_->{to} == $city->cityId);
         }
         # we attack one city maximum 4 times a day.
         next if($c >= 4);