changeset 202:2c2dcbcc5c4d

upgrade warehouse for next city
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Mon, 03 Nov 2008 13:36:34 +0800
parents eec013e81fb0
children 60f4ce7e1f63
files agent.pl city.yaml
diffstat 2 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/agent.pl	Mon Nov 03 13:10:50 2008 +0800
+++ b/agent.pl	Mon Nov 03 13:36:34 2008 +0800
@@ -42,9 +42,21 @@
     return 1 if($city->{buildings}->{townHall} >= 20);
     # TODO 應該以 成長率 * 升級所需時間計算
     # 6 hours earlier, we upgrade the twonHall.
-    return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*6)) ?  0 : 1)
+    return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*8)) ?  0 : 1)
 }
 
+sub is_warehouse_enough {
+    my ($self, $city) = @_;
+    my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);
+    my @cities = keys(%{$self->{ikariam}->{cities}});
+    my $nextCities = $#cities + 1;
+
+    Carp::carp(sprintf("Required warehouse level %s, current is %s\n", $warehouse[$nextCities], $city->{buildings}->{warehouse}));
+    return 0 if(!defined($city->{buildings}->{warehouse}));
+    return ($city->{buildings}->{warehouse} >= $warehouse[$nextCities]) ? 1 : 0;
+}
+
+
 sub is_warehouse_enougn_for_governorsresidence {
     my ($self, $city) = @_;
     my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);
@@ -90,12 +102,6 @@
     return ($city->{tavern}->{maxValue} == $city->{tavern}->{iniValue} ? 1 : 0);
 }
 
-sub is_warehouse_enough {
-    my ($self, $city) = @_;
-    # TODO 以速率計算容納率
-    return 1;
-}
-
 sub is_gold_enoughforcargo {
     my ($self, $city) = @_;
     my @cargoCost = qw/160 244 396 812 1240 1272 1832 1888 3848 3972 5204 5384 6868 7120 8864 9200 11268 11712 14108 14680 23320 24288 28664 29880 34956 36468 42348 44212 51024 53308 61236 64024 73096 76468 87020 91088 103224 116524 122072 137432 180060 202132 211964 237444 249108 278276 292076 306623 321963 338138 355198 373191 392171 412195 433320 455612 479135 503962 530166 557828 587031 617863 650420 684802 721113 759466 799981 842783 888005 935790 986286 1039654 1096062 1155689 1218724 1285369 1355837 1430353 1509159 1592508 1680670 1773932 1872597 1976989 2087448 2204338 2328045 2458976 2597567 2744276 2899594 3064040 3238163 3422550 3617820 3824635 4043693 4275738 4521561 4782000 5057946 5350345 5660202 5988585 6336630 6705540 7096598 7511164 7950683 8416694 8910828 9434823 9990523 10579889 11205006 11868090 12571498 13317734 14109462 14949514/;
--- a/city.yaml	Mon Nov 03 13:10:50 2008 +0800
+++ b/city.yaml	Mon Nov 03 13:36:34 2008 +0800
@@ -1,3 +1,4 @@
+# TODO adjust human resources
 ---
 # city level
 # 基本建設規則
@@ -5,10 +6,9 @@
 - is_attacked:
     # we are in Peace :D
     0:
-      # TODO adjust human resources
       - is_constructing:
          0:
-            # XXX: 這樣會一口氣買同等城市數量的船耶
+            # FIXME: 這樣會一口氣買同等城市數量的船耶, 應拉出至全國金錢考量
             # - is_gold_enoughforcargo:
                # 1: increaseTransporter
             - is_corruption:
@@ -24,9 +24,6 @@
                            1: build_townHall
                   - is_wall_enough:
                      0: build_wall
-                  # 倉庫庫存量
-                  - is_warehouse_enough:
-                     0: build_warehouse
                   - is_happiness:
                      0:
                         - is_winepress_researched:
@@ -49,6 +46,8 @@
                            1:
                               - is_barracks_level_enough:
                                  0: build_barracks
+                  - is_warehouse_enough:
+                     0: build_warehouse
             # TODO
             # build_safehouse
             # is_espionage_researched
@@ -61,12 +60,9 @@
             #       - build_workshop 
             # build_academy
 
-            # build_palace (Expansion, Capital only)
-
             # 大使館
             # build_embassy 
 
-            # 要蓋到何種程度?
             # is_culturalexchange_resaerched
             #    1: 
             #       - build_museum