changeset 153:25dcc1fffeef

friend or foe identification
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sat, 01 Nov 2008 04:29:08 +0800
parents 60a09758a885
children 1499b0d496b6
files warfare.pl
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/warfare.pl	Sat Nov 01 04:09:52 2008 +0800
+++ b/warfare.pl	Sat Nov 01 04:29:08 2008 +0800
@@ -60,12 +60,16 @@
 
 sub locateVictim {
     my ($self, $city, $x, $y, $tradegood) = @_;
+
+    my $user = Ikariam::User->search('name' => $::user);
+
     my @cities = Ikariam::Cities->search_sheeps(($x + 6), ($x - 6), ($y + 6), ($y - 6));
-
     foreach my $city (@cities) {
         my $sheep = $city->user;
         my $island = $city->island;
 
+        # we don't fight with members in same ally.
+        next if($sheep->allyId == $user->allyId);
         # we fight for island which ownes differnet trade goods.
         next if($island->tradegood == $tradegood);
         # Ignore the user in vacation which we can not attack.
@@ -106,6 +110,8 @@
 
 sub engagement {
     my ($self, $cityId, $x, $y, $tradegood) = @_;
+    print($::i);
+    exit;
     my $victim = $self->locateVictim($cityId, $x, $y, $tradegood);
     if(defined($victim)) {
         $self->{ikariam}->changeCity($cityId);