Mercurial > eagle-eye
diff agent.pl @ 87:4c82cf844aa8
counting navy expenditure
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Sun, 26 Oct 2008 15:02:06 +0800 |
parents | a8acf50bf7bb |
children | 86402d28544f |
line wrap: on
line diff
--- a/agent.pl Sun Oct 26 14:30:58 2008 +0800 +++ b/agent.pl Sun Oct 26 15:02:06 2008 +0800 @@ -170,9 +170,35 @@ # TODO } +# navy +sub rule_navyExpenditure +{ + my ($self, $cityId) = @_; + # move this to somewhere else. + my $workersRatio = { + 'citizens' => 0.4, + 'specialworkers' => 0.3, + 'woodworkers' => 0.7, + }; + + my $currentCost = $self->{'ikariam'}->getNavyExpenditure($cityId); + my $netincome = $self->{'ikariam'}->getNetIncome($cityId); + + # 軍費為 兩成 淨收入 + # 陸軍佔用 0.8 + # 海軍佔用 0.2 + my $militaryExpenditure = int($netincome * 0.2 * 0.2); + + if($currentCost < $militaryExpenditure) { + printf("Current navy expenditure total=%s, affordable %s\n", $currentCost, $militaryExpenditure); + } +} + +# army sub rule_milityExpenditure { my ($self, $cityId) = @_; + # move this to somewhere else. my $workersRatio = { 'citizens' => 0.4, 'specialworkers' => 0.3, @@ -183,14 +209,13 @@ my $netincome = $self->{'ikariam'}->getNetIncome($cityId); # 軍費為 兩成 淨收入 - my $militaryExpenditure = int($netincome * 0.2); + # 陸軍佔用 0.8 + # 海軍佔用 0.2 + my $militaryExpenditure = int($netincome * 0.2 * 0.8); if($currentCost < $militaryExpenditure) { - printf("Current mility expenditure total=%s, affordable %s\n", $currentCost, $militaryExpenditure); + printf("Current army expenditure total=%s, affordable %s\n", $currentCost, $militaryExpenditure); } - - # TODO, 海軍 - } 1; @@ -231,8 +256,9 @@ # maybe this should be moved to Rules. $i->blanceHurmanResource($cityId); - # + # milityExpenditure $rules->rule_milityExpenditure($cityId); + $rules->rule_navyExpenditure($cityId); # build and upgrade for cities $tree = LoadFile('city.yaml');