diff planner.pl @ 301:07f51bb67e56

option for wave attack
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 07 Dec 2008 22:25:30 +0800
parents 523ea51126bc
children 50cff2eee239
line wrap: on
line diff
--- a/planner.pl	Sun Dec 07 21:13:21 2008 +0800
+++ b/planner.pl	Sun Dec 07 22:25:30 2008 +0800
@@ -3,6 +3,7 @@
 use Data::Dumper;
 use Decision::ParseTree q{ParseTree};
 use YAML qw/LoadFile Dump DumpFile/;
+use Getopt::Std;
 
 Ikariam::Cities->has_a(island => 'Ikariam::Island');
 
@@ -41,6 +42,7 @@
 }
 
 package main;
+getopts('w');
 if($#ARGV < 2) {
     die("Usage: %s targetCity navyCity armyCity wingman1.. wingman2..\n");
 }
@@ -66,9 +68,14 @@
 push (@cities, $city);
 
 # wingman, army
-foreach my $cityId (@wingman) {
+foreach my $i (0..$#wingman) {
+    my $cityId = $wingman[$i];
     my $city = LoadFile(sprintf("city-%s-dump.yaml", $cityId));
-    $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 20);
+    if(defined($opt_w)) {
+        $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 20) - ($i * 20 + 20);
+    } else {
+        $city->{distance} = travelTime($targetCity->island->x, $targetCity->island->y, $city->{island}->{x}, $city->{island}->{y}, 20);
+    }
     push (@cities, $city);
 }