changeset 296:1d0a55318262

merged
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 07 Dec 2008 15:10:51 +0800
parents 15c288dd7dc5 (diff) 73c9bf517155 (current diff)
children 073442284ec1
files Ikariam.pm
diffstat 3 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Ikariam.pm	Fri Dec 05 22:49:36 2008 +0800
+++ b/Ikariam.pm	Sun Dec 07 15:10:51 2008 +0800
@@ -351,6 +351,17 @@
     return @cities;
 }
 
+sub switchCityBySafehouseLevel {
+    my $self = shift;
+}
+
+sub viewSendSpy {
+    my $self = shift;
+    my $cityId = shift;
+    my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=sendSpy&destinationCityId=%d', $self->{server}, $cityId));
+    return Ikariam::Extractor->new(content => $res->content)->find(sprintf('//div[@class="percentage"]/text()'));
+}
+
 sub increaseTransporter {
     my $self = shift;
     my $param = shift;
--- a/scan.pl	Fri Dec 05 22:49:36 2008 +0800
+++ b/scan.pl	Sun Dec 07 15:10:51 2008 +0800
@@ -17,7 +17,6 @@
 
 sub new {
     my($class, $i) = @_;
-    warn("new scanner");
     my $self = {
         ikariam => $i,
     };
@@ -47,6 +46,8 @@
         } else {
             $c = Ikariam::Cities->insert($h_city);
         }
+ 
+        $c->set(risk => $self->{ikariam}->viewSendSpy($h_city->{cityId}));
         $c->update();
 
         my $user = Ikariam::User->retrieve($h_city->{'user'});
--- a/sheep.pl	Fri Dec 05 22:49:36 2008 +0800
+++ b/sheep.pl	Sun Dec 07 15:10:51 2008 +0800
@@ -75,9 +75,9 @@
             # 測試風險評估
             # $capture = $capture - ($sheep->army_score_main*100);
                         
-            $line = sprintf("%d %s score %d army %d %s/%s,", 
+            $line = sprintf("%d %s score %d army %d risk %d %s/%s,", 
                 $capture,
-                $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally);
+                $c->status, $sheep->score, $sheep->army_score_main, $c->risk, $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,