Mercurial > eagle-eye
comparison planner.pl @ 358:58351fccf619
default unit number is now 0, for avoid stupid thing
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Mon, 23 Feb 2009 16:24:22 +0800 |
parents | 72df6f5bd05d |
children | 2444685c68c9 |
comparison
equal
deleted
inserted
replaced
357:f9a6b226fb79 | 358:58351fccf619 |
---|---|
53 } | 53 } |
54 my $targetCityId = shift(@ARGV); | 54 my $targetCityId = shift(@ARGV); |
55 my $navyCity = shift(@ARGV); | 55 my $navyCity = shift(@ARGV); |
56 my $armyCity = shift(@ARGV); | 56 my $armyCity = shift(@ARGV); |
57 my @wingman = @ARGV; | 57 my @wingman = @ARGV; |
58 my $vanguard = 21; | |
58 | 59 |
59 my $targetCity = Ikariam::Cities->retrieve($targetCityId); | 60 my $targetCity = Ikariam::Cities->retrieve($targetCityId); |
60 | 61 |
61 | |
62 # NAVY | 62 # NAVY |
63 my $city = LoadFile(sprintf("city-%s-dump.yaml", $navyCity)); | 63 my $city = LoadFile(sprintf("city-%s-dump.yaml", $navyCity)); |
64 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 33) + 45; | 64 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 33) + $vanguard + 8; |
65 $city->{type} = "navy"; | 65 $city->{type} = "navy"; |
66 push (@cities, $city); | 66 push (@cities, $city); |
67 | 67 |
68 # ARMY | 68 # ARMY |
69 my $city = LoadFile(sprintf("city-%s-dump.yaml", $armyCity)); | 69 my $city = LoadFile(sprintf("city-%s-dump.yaml", $armyCity)); |
70 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 60) + 5; | 70 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 60) + $vanguard + 5; |
71 $city->{type} = "army"; | 71 $city->{type} = "army"; |
72 push (@cities, $city); | 72 push (@cities, $city); |
73 | 73 |
74 # wingman, army | 74 # wingman, army |
75 foreach my $i (0..$#wingman) { | 75 foreach my $i (0..$#wingman) { |
82 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 60); | 82 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 60); |
83 } | 83 } |
84 push (@cities, $city); | 84 push (@cities, $city); |
85 } | 85 } |
86 | 86 |
87 @cities = sort { $a->{distance} <=> $b->{distance}; } (@cities); | |
88 | |
89 | |
90 # print the code. | 87 # print the code. |
91 print <<EOF; | 88 print <<EOF; |
92 #!/usr/bin/perl | 89 #!/usr/bin/perl |
93 use strict; | 90 use strict; |
94 use Ikariam; | 91 use Ikariam; |
95 use Data::Dumper; | 92 use Data::Dumper; |
96 package main; | 93 package main; |
97 my \$ikariam = new Ikariam(\$::server, \$::user, \$::pass); | 94 my \$ikariam = new Ikariam(\$::server, \$::user, \$::pass); |
98 EOF | 95 EOF |
96 | |
97 foreach(@cities) { | |
98 printf("# %s %s (%s)\n", $_->{type}, $_->{id}, $_->{distance}); | |
99 } | |
100 @cities = sort { $a->{distance} <=> $b->{distance}; } (@cities); | |
99 | 101 |
100 printf ("# %s %s [%s:%s]\n", $targetCity->owner, $targetCity->cityname, $targetCity->island->x, $targetCity->island->y); | 102 printf ("# %s %s [%s:%s]\n", $targetCity->owner, $targetCity->cityname, $targetCity->island->x, $targetCity->island->y); |
101 printf ("# http://%s/index.php?view=island&id=%d&selectCity=%d\n", $::server, $targetCity->island->id, $targetCity->id); | 103 printf ("# http://%s/index.php?view=island&id=%d&selectCity=%d\n", $::server, $targetCity->island->id, $targetCity->id); |
102 | 104 |
103 for(my $i = ($#cities + 1) ; $i-- ; $i < 0 ) { | 105 for(my $i = ($#cities + 1) ; $i-- ; $i < 0 ) { |
113 | 115 |
114 printf('$ikariam->login;' . "\n"); | 116 printf('$ikariam->login;' . "\n"); |
115 if($cities[$i]->{type} eq "navy") { | 117 if($cities[$i]->{type} eq "navy") { |
116 printf('$ikariam->changeCity(%d);' . "\n", $cities[$i]->{id}); | 118 printf('$ikariam->changeCity(%d);' . "\n", $cities[$i]->{id}); |
117 printf('$ikariam->blockadeCity(%d, {' . "\n", $targetCity->id); | 119 printf('$ikariam->blockadeCity(%d, {' . "\n", $targetCity->id); |
118 printf("\tblockadeDuration => 2*60*60," . "\n"); | 120 printf("\tblockadeDuration => 8*60*60," . "\n"); |
119 while (my ($k, $v) = each(%{$cities[$i]->{fleet}})) { | 121 while (my ($k, $v) = each(%{$cities[$i]->{fleet}})) { |
120 if($v > 0) { | 122 if($v > 0) { |
121 printf("\tcargo_fleet_%s => %s, # %s \n", $fleet->{$k}, $v, $k); | 123 printf("\tcargo_fleet_%s => %s, # %s (%d)\n", $fleet->{$k}, 0, $k, $v); |
122 } | 124 } |
123 } | 125 } |
124 printf('});' . "\n", $cities[$i]->{id}); | 126 printf('});' . "\n", $cities[$i]->{id}); |
125 } else { | 127 } else { |
126 printf('$ikariam->changeCity(%d);' . "\n", $cities[$i]->{id}); | 128 printf('$ikariam->changeCity(%d);' . "\n", $cities[$i]->{id}); |
127 printf('$ikariam->plunderCity(%d, {' . "\n", $targetCity->id); | 129 printf('$ikariam->plunderCity(%d, {' . "\n", $targetCity->id); |
128 while (my ($k, $v) = each(%{$cities[$i]->{army}})) { | 130 while (my ($k, $v) = each(%{$cities[$i]->{army}})) { |
129 if($v > 0) { | 131 if($v > 0) { |
130 printf("\tcargo_army_%s => %s, # %s \n", $army->{$k}, $v, $k); | 132 printf("\tcargo_army_%s => %s, # %s (%d)\n", $army->{$k}, 0, $k, $v); |
131 } | 133 } |
132 } | 134 } |
133 printf("\ttransporter => %s, # transporter\n", $cities[$i]->{transporters}->{avail}); | 135 printf("\ttransporter => %s, # transporter\n", $cities[$i]->{transporters}->{avail}); |
134 printf('});' . "\n", $cities[$i]->{id}); | 136 printf('});' . "\n", $cities[$i]->{id}); |
135 } | 137 } |
136 printf('$ikariam->logout;' . "\n"); | 138 printf('$ikariam->logout;' . "\n"); |
137 } | 139 } |