changeset 107:554bdd49c703

we should also count the force which is coming back
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Wed, 29 Oct 2008 15:21:15 +0800
parents 31803acb9c5f
children d3bece9b06b2
files warfare.pl
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/warfare.pl	Wed Oct 29 15:14:58 2008 +0800
+++ b/warfare.pl	Wed Oct 29 15:21:15 2008 +0800
@@ -75,11 +75,12 @@
         # check if we over-attacked
         my $c = Ikariam::Report->search_attack($city->cityId, time - 24*60*60 - 7*60*60)->count();
         # check the current plunders
-        foreach (@{$self->{ikariam}->{'military'}->{'homeland'}}) {
-            $c++ if($_->{to} eq $city->cityId);
+        foreach ($self->{ikariam}->{'military'}->{'homeland'}) {
+            $c++ if($_{to} eq $city->cityId);
+            $c++ if($_{from} eq $city->cityId);
         }
         next if($c >= 4);
-        
+
         # {
         # if(1) {
             my $capture = $city->citylevel * ($city->citylevel - 1) * $sheep->trader_score_secondary / 10000;
@@ -118,6 +119,7 @@
 my $cities = $i->check;
 $i->checkMilitaryAdvisorCombatReports();
 
+
 foreach my $cityId (keys(%$cities)) {
     print Dump($i->{'military'});
     # build and upgrade for cities