changeset 338:824f949bc484

we attack zero army victim every 3 days
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Thu, 12 Feb 2009 03:59:24 +0800
parents 025a36717f2c
children a3cbe8bb4890 fe740b1c6f94
files Ikariam.pm warfare.pl
diffstat 2 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Ikariam.pm	Thu Feb 12 03:25:32 2009 +0800
+++ b/Ikariam.pm	Thu Feb 12 03:59:24 2009 +0800
@@ -852,22 +852,24 @@
     $self->{'military'}->{wars} = 0;
     $self->{'military'}->{attack} = 0;
 
+# FIXME, we don't if there is a attack.
     foreach (qw/homeland elsewhere/) {
         $self->{'military'}->{$_} = ();
-        my $result = $extractor->{doc}->find(sprintf('//div[@id="%s"]//ul[@id="battleReports"]/li[@class="enroute"]', $_));
+        my $result = $extractor->{doc}->find(sprintf('//table[@class="locationEvents"]//tr[position() > 1]', $_));
         foreach my $div ( @$result ) {
             my $extractor = new Ikariam::Extractor(content => $div->toString(1));
-            my $f = $extractor->find('//div[@class="report"]/a[1]/@href');
-            my $t = $extractor->find('//div[@class="report"]/a[2]/@href');
+            my $f = $extractor->find('//td[4]/a/@href');
+            my $t = $extractor->find('//td[8]/a/@href');
             $f = $1 if($f =~ /\?view=island&cityId=(\d+)/);
             $t = $1 if($t =~ /\?view=island&cityId=(\d+)/);
 
             push @{$self->{'military'}->{$_}}, { from => $f, to => $t};
-            if($_ eq 'homeland') {
-                $self->{'military'}->{wars}++;
-            } else {
-                $self->{'military'}->{attack}++;
-            }
+
+#            if($_ eq 'homeland') {
+#                $self->{'military'}->{wars}++;
+#            } else {
+#                $self->{'military'}->{attack}++;
+#            }
         }
     }
 }
--- a/warfare.pl	Thu Feb 12 03:25:32 2009 +0800
+++ b/warfare.pl	Thu Feb 12 03:59:24 2009 +0800
@@ -108,7 +108,7 @@
         }
 
         # check if we over-attacked
-        my $c = Ikariam::Report->search_victim($city->cityId, time - 24*60*60 - 7*60*60)->count();
+        my $c = Ikariam::Report->search_victim($city->cityId, time - 24*60*60 * 3)->count();
         # check the current plunders
         foreach (@{$self->{ikariam}->{'military'}->{'homeland'}}) {
             # counting for both leaving and coming back.
@@ -117,7 +117,7 @@
             # we don't attack same city twice at same time.
             next CITY if($_->{to} == $city->cityId);
         }
-        next CITY if($c >= 1);
+        next CITY if($c ge 1);
 
         my $capture = $city->citylevel * ($city->citylevel - 1) * $sheep->trader_score_secondary / 10000;
         next if($capture < 1500);