comparison planner.pl @ 328:6782280a886b

merged
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Thu, 12 Feb 2009 01:19:27 +0800
parents 0db3e2bcbd0f
children 65f45552060e
comparison
equal deleted inserted replaced
326:58b36b18809f 328:6782280a886b
54 my $targetCity = Ikariam::Cities->retrieve($targetCityId); 54 my $targetCity = Ikariam::Cities->retrieve($targetCityId);
55 55
56 56
57 # NAVY 57 # NAVY
58 my $city = LoadFile(sprintf("city-%s-dump.yaml", $navyCity)); 58 my $city = LoadFile(sprintf("city-%s-dump.yaml", $navyCity));
59 # $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 8) + 45; 59 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 33) + 25;
60 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 8) + 25;
61 $city->{type} = "navy"; 60 $city->{type} = "navy";
62 push (@cities, $city); 61 push (@cities, $city);
63 62
64 # ARMY 63 # ARMY
65 my $city = LoadFile(sprintf("city-%s-dump.yaml", $armyCity)); 64 my $city = LoadFile(sprintf("city-%s-dump.yaml", $armyCity));
66 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 20) + 5; 65 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 50) + 5;
67 $city->{type} = "army"; 66 $city->{type} = "army";
68 push (@cities, $city); 67 push (@cities, $city);
69 68
70 # wingman, army 69 # wingman, army
71 foreach my $i (0..$#wingman) { 70 foreach my $i (0..$#wingman) {
72 my $cityId = $wingman[$i]; 71 my $cityId = $wingman[$i];
73 my $city = LoadFile(sprintf("city-%s-dump.yaml", $cityId)); 72 my $city = LoadFile(sprintf("city-%s-dump.yaml", $cityId));
74 $city->{type} = "wingman" . ($i+1); 73 $city->{type} = "wingman" . ($i+1);
75 if(defined($opt_w)) { 74 if(defined($opt_w)) {
76 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 20) - ($i * 20 + 20); 75 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 50) - ($i * 20 + 20);
77 } else { 76 } else {
78 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 20); 77 $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 50);
79 } 78 }
80 push (@cities, $city); 79 push (@cities, $city);
81 } 80 }
82 81
83 @cities = sort { $a->{distance} <=> $b->{distance}; } (@cities); 82 @cities = sort { $a->{distance} <=> $b->{distance}; } (@cities);
124 while (my ($k, $v) = each(%{$cities[$i]->{army}})) { 123 while (my ($k, $v) = each(%{$cities[$i]->{army}})) {
125 if($v > 0) { 124 if($v > 0) {
126 printf("\tcargo_army_%s => %s, # %s \n", $army->{$k}, $v, $k); 125 printf("\tcargo_army_%s => %s, # %s \n", $army->{$k}, $v, $k);
127 } 126 }
128 } 127 }
128 printf("\ttransporter => %s, # transporter\n", $cities[$i]->{transporters}->{avail});
129 printf('});' . "\n", $cities[$i]->{id}); 129 printf('});' . "\n", $cities[$i]->{id});
130 } 130 }
131 printf('$ikariam->logout;' . "\n"); 131 printf('$ikariam->logout;' . "\n");
132 } 132 }