changeset 197:dbdd7dcc91c6

fixed for friendly troop and corruption
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Mon, 03 Nov 2008 03:17:43 +0800
parents ad88b3c92383
children 2dfeb4371db7
files Ikariam.pm agent.pl military.yaml warfare.pl
diffstat 4 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Ikariam.pm	Mon Nov 03 02:00:29 2008 +0800
+++ b/Ikariam.pm	Mon Nov 03 03:17:43 2008 +0800
@@ -972,7 +972,6 @@
     # MilitaryAdvisor
     $self->checkMilitaryAdvisorMilitaryMovements();
     $self->checkMilitaryAdvisorCombatReports();
-    $self->checkFriends();
     $self->{'research'} = $self->checkResearch((keys(%{$self->{'cities'}}))[0]);
 
     # alerts
@@ -988,6 +987,7 @@
         $self->checkArmies($cityId);
         $self->checkTavern($cityId);
     }
+    # $self->checkFriends();
     return $self->{'cities'};
 }
 
--- a/agent.pl	Mon Nov 03 02:00:29 2008 +0800
+++ b/agent.pl	Mon Nov 03 03:17:43 2008 +0800
@@ -47,10 +47,11 @@
 
 sub is_warehouse_enougn_for_governorsresidence {
     my ($self, $city) = @_;
-    my @warehouse = (qw/undef 0 4 9 16 18 19 20 21 22 23 24 25/);
+    my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);
     my @cities = keys(%{$self->{ikariam}->{cities}});
 
-    return ($city->{buildings}->{warehouse} < $warehouse[$#cities]) ? 0 : 1;
+    Carp::carp(sprintf("Required warehouse level %s, current is %s only\n", $warehouse[$#cities], $city->{buildings}->{warehouse}));
+    return ($city->{buildings}->{warehouse} > $warehouse[$#cities]) ? 0 : 1;
 }
 
 sub is_corruption {
@@ -236,7 +237,7 @@
 
 sub is_barracks_upgrading {
     my ($self, $city) = @_;
-    return $::i->is_barracks_upgrading($city->{id});
+    return $self->{ikariam}->is_barracks_upgrading($city->{id});
 }
 
 sub is_army_trainning {
@@ -263,7 +264,8 @@
 # navy
 sub is_navyExpenditure_available
 {
-    my ($self, $cityId) = @_;
+    my ($self, $city) = @_;
+    my $cityId = $city->{id};
 
     # move this to somewhere else.
     my $workersRatio = {
@@ -290,7 +292,9 @@
 # army
 sub is_milityExpenditure_available
 {
-    my ($self, $cityId) = @_;
+    my ($self, $city) = @_;
+    my $cityId = $city->{id};
+
     # move this to somewhere else.
     my $workersRatio = {
         'citizens' => 0.4,
@@ -358,7 +362,6 @@
     }
     DumpFile("army-dump.yaml", $cities);
 
-
     # build and upgrade for cities
     $tree  = LoadFile('city.yaml');
     $cities->{$cityId}->{parse_path} = [];
--- a/military.yaml	Mon Nov 03 02:00:29 2008 +0800
+++ b/military.yaml	Mon Nov 03 03:17:43 2008 +0800
@@ -8,7 +8,9 @@
                   - is_shipyard_level_enough:
                      0: 
                         - is_constructing:
-                           0: build_shipyard
+                           0: 
+                              - is_any_corruption:
+                                 0: build_shipyard
                      1:
                         - is_shipyard_upgrading:
                            0:
@@ -28,7 +30,9 @@
                   - is_barracks_level_enough:
                      0:
                         - is_constructing:
-                           0: build_barracks
+                           0: 
+                              - is_any_corruption:
+                                 0: build_barracks
                      1:
                         - is_barracks_upgrading:
                            0:
--- a/warfare.pl	Mon Nov 03 02:00:29 2008 +0800
+++ b/warfare.pl	Mon Nov 03 03:17:43 2008 +0800
@@ -143,6 +143,7 @@
 $i->login;
 my $cities = $i->check;
 $i->checkMilitaryAdvisorCombatReports();
+$i->checkFriends();
 
 foreach my $cityId (keys(%$cities)) {
     print Dump($i->{'military'});