Mercurial > eagle-eye
comparison sheep.pl @ 343:85d60a0569bf
fixed travel time for 0.3.0
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 12 Feb 2009 21:14:47 +0800 |
parents | 6296a9cd6878 |
children | b245f259776f |
comparison
equal
deleted
inserted
replaced
342:f3bdbc706a37 | 343:85d60a0569bf |
---|---|
39 } | 39 } |
40 ); | 40 ); |
41 | 41 |
42 sub travelTime { | 42 sub travelTime { |
43 my ($x1, $y1, $x2, $y2, $speed) = @_; | 43 my ($x1, $y1, $x2, $y2, $speed) = @_; |
44 $speed = 20 unless(defined($speed)); | 44 $speed = 60 unless(defined($speed)); |
45 return int( (sqrt((abs($x1 - $x2) * abs($x1 - $x2)) + (abs($y1 - $y2) * abs($y1 - $y2)))+1) * (400/$speed)); | 45 if($x1 == $x2 && $y1 == $y2) { |
46 return 600/$speed; | |
47 } else { | |
48 return int( (sqrt((abs($x1 - $x2) * abs($x1 - $x2)) + (abs($y1 - $y2) * abs($y1 - $y2)))) * (1200/$speed)); | |
49 } | |
46 } | 50 } |
47 | 51 |
48 sub listSheeps | 52 sub listSheeps |
49 { | 53 { |
50 my @sheeps = @_; | 54 my @sheeps = @_; |
71 } | 75 } |
72 } | 76 } |
73 | 77 |
74 my $island = Ikariam::Island->retrieve($c->island); | 78 my $island = Ikariam::Island->retrieve($c->island); |
75 | 79 |
76 # 所得金錢 = 對方城鎮等級x(對方城鎮等級-1)x對方金錢/10000 | |
77 my $capture = $c->citylevel * ($c->citylevel - 1) * $sheep->trader_score_secondary / 10000; | |
78 | 80 |
79 next if($capture < 200); | |
80 | |
81 # 測試風險評估 | |
82 # $capture = $capture - ($sheep->army_score_main*100); | |
83 | |
84 $line = sprintf("%d %s score %d army %d risk %d %s/%s,", | 81 $line = sprintf("%d %s score %d army %d risk %d %s/%s,", |
85 travelTime($::x, $::y, $island->x, $island->y), | 82 travelTime($::x, $::y, $island->x, $island->y), |
86 # $capture, | 83 # $capture, |
87 $c->status, $sheep->score, $sheep->army_score_main, $c->risk, $sheep->name, $sheep->ally); | 84 $c->status, $sheep->score, $sheep->army_score_main, $c->risk, $sheep->name, $sheep->ally); |
88 | 85 |