diff sheep.pl @ 240:937fc672df56

count by Ally's score
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Fri, 07 Nov 2008 15:01:11 +0800
parents 9b8aa30a532c
children 64549ddddf4a
line wrap: on
line diff
--- a/sheep.pl	Fri Nov 07 11:46:03 2008 +0800
+++ b/sheep.pl	Fri Nov 07 15:01:11 2008 +0800
@@ -5,6 +5,10 @@
 
 package main;
 my $mime = Ikariam::User->retrieve ('name' => $::user);
+my $myAlly = undef;
+$myAlly = Ikariam::Ally->retrieve($mime->allyId)
+    if(defined($mime->allyId) && $mime->allyId ne '0');
+
 # only challenge the small victims
 my $army_score_main = ($mime->army_score_main / 3);
 
@@ -45,14 +49,6 @@
         # avoid duplicate
         next if($sheep->id == $s); $s = $sheep->id;
 
-        # 查聯盟數量
-        my $members = 1;
-        unless ($sheep->allyId == '0') {
-            unless (!defined($sheep->allyId) || $sheep->allyId == 0) {
-                my $ally = Ikariam::Ally->retrieve($sheep->allyId);
-                $members = $ally->members;
-            }
-        }
 
         foreach my $c ($sheep->cities) {
             my $line = "";
@@ -60,9 +56,13 @@
             next if($c->status eq 'v');
 
             unless($c->status eq 'i') {
-                # Ignore 聯盟人數大於五
-                # TODO 應該依照影響力來分
-                next if($members > 10);
+                # 依照影響力區分
+                unless ($sheep->allyId == '0') {
+                    unless (!defined($sheep->allyId) || $sheep->allyId == 0) {
+                        my $ally = Ikariam::Ally->retrieve($sheep->allyId);
+                        next if($ally->score > $myAlly->score);
+                    }
+                }
             }
 
             my $island = Ikariam::Island->retrieve($c->island);
@@ -75,9 +75,9 @@
             # 測試風險評估
             # $capture = $capture - ($sheep->army_score_main*100);
                         
-            $line = sprintf("%d %s score %d army %d %s/%s(%d),", 
+            $line = sprintf("%d %s score %d army %d %s/%s,", 
                 $capture,
-                $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally, $members);
+                $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally);
 
             $line .= sprintf("\"%s\" %d [%d,%d] %s http://%s/index.php?view=island&id=%d&selectCity=%d\n",
                 $c->cityname, $c->citylevel,