diff Ikariam.pm @ 86:a8acf50bf7bb

implemented a simple MilityExpenditure counting
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 26 Oct 2008 14:30:58 +0800
parents 2c6c219dc3ff
children 4c82cf844aa8
line wrap: on
line diff
--- a/Ikariam.pm	Sun Oct 26 12:26:43 2008 +0800
+++ b/Ikariam.pm	Sun Oct 26 14:30:58 2008 +0800
@@ -692,6 +692,50 @@
     return ($self->{cities}->{$cityId}->{citizens}->{total}*4 - $self->{cities}->{$cityId}->{citizens}->{scientists}*8 );
 }
 
+sub getMilityExpenditure {
+    my $self = shift;
+    my $cityId = shift;
+    my $cities = $self->{cities};
+    my $troops = {
+        # p 需要人口
+        # w 木頭
+        # S 硫磺
+        # b 製造時間
+        # u 維持費用
+        # m 最低軍營等級
+        # o 最佳軍營等級
+        # a 攻擊力
+        # d 防守力
+        # A 
+        # D 
+        # s 耐力
+        # c 種類
+        # v speed
+        # x 加成 Assault, Resistance
+        Slinger => {n=>"Slinger",p=>1,w=>40,b=>"12m",u=>8,m=>1,o=>4,a=>7,d=>6,A=>2,D=>2,s=>10,c=>"Human",v=>20},
+        Swordsman => {n=>"Swordsman",p=>2,w=>47,S=>16,b=>"17m",u=>16,m=>3,o=>5,a=>18,d=>14,A=>4,D=>3,s=>12,c=>"Human",v=>20,x=>"Assault"},
+        Phalanx => {n=>"Phalanx",p=>4,w=>104,S=>64,b=>"40m",u=>24,m=>4,o=>7,a=>24,d=>40,A=>6,D=>10,s=>14,c=>"Human",v=>20,x=>"Resistance"},
+        Ram => {n=>"Ram",p=>8,w=>198,S=>128,b=>"42m",u=>52,m=>5,o=>8,a=>14,d=>18,A=>3,D=>4,s=>16,c=>"Machina",v=>20,x=>"Ram"},
+        Archer => {n=>"Archer",p=>4,w=>172,S=>86,b=>"49m",u=>32,m=>7,o=>10,a=>40,d=>40,A=>10,D=>10,s=>12,c=>"Human",v=>20},
+        Catapult => {n=>"Catapult",p=>10,w=>342,S=>232,b=>"49m",u=>72,m=>10,o=>14,a=>36,d=>28,A=>9,D=>7,s=>16,c=>"Machina",v=>20,x=>"Ram"},
+        Gunsman => {n=>"Gunsman",i=>"marksman",p=>7,w=>355,S=>154,b=>"1h 23m",u=>58,m=>14,o=>18,a=>80,d=>64,A=>18,D=>14,s=>10,c=>"Human",v=>20},
+        Mortar => {n=>"Mortar",p=>12,w=>1325,S=>938,b=>"1h 53m",u=>128,m=>19,o=>21,a=>64,d=>64,A=>15,D=>15,s=>16,c=>"Machina",v=>20,x=>"Ram"},
+        SteamGiant => {n=>"SteamGiant",i=>"steamgiant",p=>6,w=>1150,S=>716,b=>"1h 45m",u=>68,m=>16,o=>20,a=>100,d=>140,A=>20,D=>30,s=>14,c=>"Machina",v=>20,x=>"Resistance"},
+        Gyrocopter => {n=>"Gyrocopter",p=>8,w=>1250,S=>670,b=>"1h 2m",u=>97,m=>12,o=>16,a=>112,d=>112,A=>25,D=>25,s=>12,c=>"Machina",v=>20},
+        Bombardier => {n=>"Bombardier",p=>24,w=>2270,S=>878,b=>"2h 10m",u=>228,m=>22,o=>24,a=>200,d=>165,A=>45,D=>35,s=>14,c=>"Machina",v=>20,x=>"Assault"},
+        Doctor => {n=>"Doctor",i=>"medic",p=>6,w=>640,C=>361,b=>"1h 2m",u=>244,m=>11,o=>12,a=>4,d=>28,A=>0,D=>0,s=>14,c=>"Human",v=>20,x=>"Healer"},
+        Cook => {n=>"Cook",p=>4,w=>520,W=>103,b=>"38m",u=>138,m=>8,o=>8,a=>6,d=>26,A=>0,D=>0,s=>16,c=>"Human",v=>20,x=>"Regeneration"}
+    };
+
+    my $cost = 0;
+
+    foreach(keys(%{$cities->{$cityId}->{army}})) {
+        # printf("%s %d = %d\n", $_, $cities->{$cityId}->{army}->{$_},  $cities->{$cityId}->{army}->{$_} * $troops->{$_}->{u});
+        $cost += $cities->{$cityId}->{army}->{$_} * $troops->{$_}->{u};
+    }
+    return $cost;
+}
+
 sub blanceHurmanResource {
     my $self = shift;
     my $cityId = shift;
@@ -713,7 +757,39 @@
     my $freePeople = $self->{cities}->{$cityId}->{citizens}->{total} - ($produceworkers + $self->{cities}->{$cityId}->{scientists});
 
     # XXX
-    Carp::carp(sprintf("suggested - produce: %s wood %s special %s\n", $produceworkers, int($freePeople*0.3), int($freePeople*0.7)));
+    # 需計算資源開挖上限, 依照島等級區分
+    # 木頭
+#   create_slider({
+#            dir : 'ltr',
+#            id : "default",
+#            maxValue : 367,
+#            overcharge : 0,
+#            iniValue : 367,
+#            bg : "sliderbg",
+#            thumb : "sliderthumb",
+#            topConstraint: -10,
+#            bottomConstraint: 344,
+#            bg_value : "actualValue",
+#            bg_overcharge : "overcharge",
+#            textfield:"inputWorkers"
+#    });
+
+#    	create_slider({
+#            dir : 'ltr',
+#            id : "default",
+#			maxValue : 367,
+#			overcharge : 0,
+#			iniValue : 367,
+#			bg : "sliderbg",
+#			thumb : "sliderthumb",
+#			topConstraint: -10,
+#			bottomConstraint: 344,
+#			bg_value : "actualValue",
+#			bg_overcharge : "overcharge",
+#			textfield:"inputWorkers"
+#	});
+
+    Carp::carp(sprintf("Suggested HR palnning - produce: %s wood %s special %s\n", $produceworkers, int($freePeople*0.3), int($freePeople*0.7)));
 }
 
 sub logout