comparison Ikariam.pm @ 330:484aaddeef66

fixed the order of armies
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Thu, 12 Feb 2009 01:50:52 +0800
parents 58b36b18809f
children 6eac624efc80
comparison
equal deleted inserted replaced
329:c29c8dad0673 330:484aaddeef66
1033 { 1033 {
1034 my $self = shift; 1034 my $self = shift;
1035 my $cityId = shift; 1035 my $cityId = shift;
1036 my %force_types; 1036 my %force_types;
1037 1037
1038 $force_types{'army'} = [ qw/undef undef Slinger Swordsman Phalanx Ram Archer Catapult Gunsman Mortar SteamGiant Gyrocopter Bombardier Doctor Cook/ ]; 1038 $force_types{'army'} = [ qw/undef undef Slinger Swordsman Phalanx Archer Gunsman Gyrocopter SteamGiant Bombardier Ram Catapult Mortar Doctor Cook/ ];
1039 $force_types{'fleet'} = [ qw/undef undef Ram-Ship BallistaShip Flamethrower CatapultShip MortarShip PaddleWheelRam DivingBoat/ ]; 1039 $force_types{'fleet'} = [ qw/undef undef Ram-Ship BallistaShip Flamethrower CatapultShip PaddleWheelRam MortarShip DivingBoat/ ];
1040 1040
1041 foreach my $x (qw/army fleet/) { 1041 foreach my $x (qw/army fleet/) {
1042 $self->{'cities'}->{$cityId}->{$x} = {}; 1042 $self->{'cities'}->{$cityId}->{$x} = {};
1043 my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=cityMilitary-%s&id=%d', $self->{server}, $x, $cityId)); 1043 my $res = $self->{mech}->get(sprintf('http://%s/index.php?view=cityMilitary-%s&id=%d', $self->{server}, $x, $cityId));
1044 my @numbers = Ikariam::Extractor->new(content => $res->content)->find('//table//tr/td'); 1044 my @numbers = Ikariam::Extractor->new(content => $res->content)->find('//table//tr/td');
1045 print(Dumper(@numbers));
1045 foreach my $j (0..$#{$force_types{$x}}) { 1046 foreach my $j (0..$#{$force_types{$x}}) {
1046 next if(!defined($force_types{$x}[$j])); 1047 next if(!defined($force_types{$x}[$j]));
1047 if ($numbers[$j] == '-') { 1048 if ($numbers[$j] == '-') {
1048 $self->{'cities'}->{$cityId}->{$x}->{$force_types{$x}[$j]} = 0; 1049 $self->{'cities'}->{$cityId}->{$x}->{$force_types{$x}[$j]} = 0;
1049 } else { 1050 } else {
1050 $self->{'cities'}->{$cityId}->{$x}->{$force_types{$x}[$j]} = $numbers[$j]; 1051 $self->{'cities'}->{$cityId}->{$x}->{$force_types{$x}[$j]} = $numbers[$j];
1051 } 1052 }
1052 } 1053 }
1053 } 1054 }
1055 print(Dumper($self->{'cities'}->{$cityId}->{'army'}));
1054 } 1056 }
1055 1057
1056 sub checkFriends 1058 sub checkFriends
1057 { 1059 {
1058 # must check cities first, so we know if we have a museum available. 1060 # must check cities first, so we know if we have a museum available.