Mercurial > eagle-eye
comparison sheep.pl @ 240:937fc672df56
count by Ally's score
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Fri, 07 Nov 2008 15:01:11 +0800 |
parents | 9b8aa30a532c |
children | 64549ddddf4a |
comparison
equal
deleted
inserted
replaced
239:38e1a82627a9 | 240:937fc672df56 |
---|---|
3 use Ikariam; | 3 use Ikariam; |
4 use Data::Dumper; | 4 use Data::Dumper; |
5 | 5 |
6 package main; | 6 package main; |
7 my $mime = Ikariam::User->retrieve ('name' => $::user); | 7 my $mime = Ikariam::User->retrieve ('name' => $::user); |
8 my $myAlly = undef; | |
9 $myAlly = Ikariam::Ally->retrieve($mime->allyId) | |
10 if(defined($mime->allyId) && $mime->allyId ne '0'); | |
11 | |
8 # only challenge the small victims | 12 # only challenge the small victims |
9 my $army_score_main = ($mime->army_score_main / 3); | 13 my $army_score_main = ($mime->army_score_main / 3); |
10 | 14 |
11 my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; | 15 my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; |
12 | 16 |
43 my $s; | 47 my $s; |
44 foreach my $sheep (sort (@sheeps)) { | 48 foreach my $sheep (sort (@sheeps)) { |
45 # avoid duplicate | 49 # avoid duplicate |
46 next if($sheep->id == $s); $s = $sheep->id; | 50 next if($sheep->id == $s); $s = $sheep->id; |
47 | 51 |
48 # 查聯盟數量 | |
49 my $members = 1; | |
50 unless ($sheep->allyId == '0') { | |
51 unless (!defined($sheep->allyId) || $sheep->allyId == 0) { | |
52 my $ally = Ikariam::Ally->retrieve($sheep->allyId); | |
53 $members = $ally->members; | |
54 } | |
55 } | |
56 | 52 |
57 foreach my $c ($sheep->cities) { | 53 foreach my $c ($sheep->cities) { |
58 my $line = ""; | 54 my $line = ""; |
59 # Ignore 假期模式 | 55 # Ignore 假期模式 |
60 next if($c->status eq 'v'); | 56 next if($c->status eq 'v'); |
61 | 57 |
62 unless($c->status eq 'i') { | 58 unless($c->status eq 'i') { |
63 # Ignore 聯盟人數大於五 | 59 # 依照影響力區分 |
64 # TODO 應該依照影響力來分 | 60 unless ($sheep->allyId == '0') { |
65 next if($members > 10); | 61 unless (!defined($sheep->allyId) || $sheep->allyId == 0) { |
62 my $ally = Ikariam::Ally->retrieve($sheep->allyId); | |
63 next if($ally->score > $myAlly->score); | |
64 } | |
65 } | |
66 } | 66 } |
67 | 67 |
68 my $island = Ikariam::Island->retrieve($c->island); | 68 my $island = Ikariam::Island->retrieve($c->island); |
69 | 69 |
70 # 所得金錢 = 對方城鎮等級x(對方城鎮等級-1)x對方金錢/10000 | 70 # 所得金錢 = 對方城鎮等級x(對方城鎮等級-1)x對方金錢/10000 |
73 next if($capture < 200); | 73 next if($capture < 200); |
74 | 74 |
75 # 測試風險評估 | 75 # 測試風險評估 |
76 # $capture = $capture - ($sheep->army_score_main*100); | 76 # $capture = $capture - ($sheep->army_score_main*100); |
77 | 77 |
78 $line = sprintf("%d %s score %d army %d %s/%s(%d),", | 78 $line = sprintf("%d %s score %d army %d %s/%s,", |
79 $capture, | 79 $capture, |
80 $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally, $members); | 80 $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally); |
81 | 81 |
82 $line .= sprintf("\"%s\" %d [%d,%d] %s http://%s/index.php?view=island&id=%d&selectCity=%d\n", | 82 $line .= sprintf("\"%s\" %d [%d,%d] %s http://%s/index.php?view=island&id=%d&selectCity=%d\n", |
83 $c->cityname, $c->citylevel, | 83 $c->cityname, $c->citylevel, |
84 $island->x, $island->y, | 84 $island->x, $island->y, |
85 $tradegoodText[$island->tradegood], | 85 $tradegoodText[$island->tradegood], |