Mercurial > eagle-eye
annotate sheep.pl @ 124:f8c97e5d77ab
translated comments.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 30 Oct 2008 17:25:20 +0800 |
parents | 94c9cde99e19 |
children | 21df8eb17a52 |
rev | line source |
---|---|
8
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
1 #!/usr/bin/perl |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
2 use strict; |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
3 use Ikariam; |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
4 use Data::Dumper; |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
5 |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
6 package main; |
95
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
7 my $mime = Ikariam::User->retrieve ('name' => $::user); |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
8 # only challenge the small victims |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
9 my $army_score_main = ($mime->army_score_main / 3); |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
10 |
18 | 11 my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; |
8
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
12 |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
13 Ikariam::User->has_many(cities => 'Ikariam::Cities'); |
102
94c9cde99e19
check the ally by right phe ally page, not counting the members we scanned.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
95
diff
changeset
|
14 Ikariam::User->has_a(ally => 'Ikariam::Ally'); |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
15 Ikariam::User->set_sql(inactivity => qq { |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
16 SELECT user.id |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
17 FROM user, cities, island |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
18 WHERE user.id == cities.user |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
19 AND cities.island == island.id |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
20 AND island.x <= ? |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
21 AND island.x >= ? |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
22 AND island.y <= ? |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
23 AND island.y >= ? |
15 | 24 AND cities.status = 'i' |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
25 } |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
26 ); |
22
552528bb4917
refined the cache timeout is 12 hours.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
18
diff
changeset
|
27 |
8
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
28 Ikariam::User->set_sql(sheeps => qq { |
24 | 29 SELECT user.id |
30 FROM user, cities | |
31 WHERE user.id == cities.user | |
95
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
32 AND user.trader_score_secondary >= user.army_score_main*3 |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
33 AND user.army_score_main <= $army_score_main |
24 | 34 AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? ) |
8
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
35 } |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
36 ); |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
37 |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
38 sub listSheeps |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
39 { |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
40 my @sheeps = @_; |
24 | 41 my %results; |
8
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
42 |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
43 my $s; |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
44 foreach my $sheep (sort (@sheeps)) { |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
45 # avoid duplicate |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
46 next if($sheep->id == $s); $s = $sheep->id; |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
47 |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
48 # 查聯盟數量 |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
49 my $members = 1; |
15 | 50 unless ($sheep->allyId == '0') { |
102
94c9cde99e19
check the ally by right phe ally page, not counting the members we scanned.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
95
diff
changeset
|
51 my $ally = $sheep->ally; |
94c9cde99e19
check the ally by right phe ally page, not counting the members we scanned.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
95
diff
changeset
|
52 $members = $ally->members; |
94c9cde99e19
check the ally by right phe ally page, not counting the members we scanned.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
95
diff
changeset
|
53 # Ikariam::User->search(allyId => $sheep->allyId)->count(); |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
54 } |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
55 |
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
56 foreach my $c ($sheep->cities) { |
24 | 57 my $line = ""; |
58 # Ignore 假期模式 | |
15 | 59 next if($c->status eq 'v'); |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
60 |
15 | 61 unless($c->status eq 'i') { |
95
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
62 # Ignore 聯盟人數大於五 |
102
94c9cde99e19
check the ally by right phe ally page, not counting the members we scanned.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
95
diff
changeset
|
63 # TODO 應該依照影響力來分 |
65
3a611c51b99b
for the new world, we only have sheep with a little gold. poor people.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
52
diff
changeset
|
64 next if($members > 5); |
15 | 65 } |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
66 |
24 | 67 my $island = Ikariam::Island->retrieve($c->island); |
68 | |
69 # 所得金錢 = 對方城鎮等級x(對方城鎮等級-1)x對方金錢/10000 | |
65
3a611c51b99b
for the new world, we only have sheep with a little gold. poor people.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
52
diff
changeset
|
70 my $capture = $c->citylevel * ($c->citylevel - 1) * $sheep->trader_score_secondary / 10000; |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
71 |
102
94c9cde99e19
check the ally by right phe ally page, not counting the members we scanned.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
95
diff
changeset
|
72 next if($capture < 200); |
33
d183277b4d93
refined the output message.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
24
diff
changeset
|
73 |
74
27b16506231f
improved the tech trees
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
65
diff
changeset
|
74 $line = sprintf("%d %s score %d army %d %s/%s(%d),", |
65
3a611c51b99b
for the new world, we only have sheep with a little gold. poor people.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
52
diff
changeset
|
75 $capture, |
74
27b16506231f
improved the tech trees
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
65
diff
changeset
|
76 $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally, $members); |
24 | 77 |
74
27b16506231f
improved the tech trees
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
65
diff
changeset
|
78 $line .= sprintf("\"%s\" %d [%d,%d] %s http://%s/index.php?view=island&id=%d&selectCity=%d\n", |
24 | 79 $c->cityname, $c->citylevel, |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
80 $island->x, $island->y, |
18 | 81 $tradegoodText[$island->tradegood], |
74
27b16506231f
improved the tech trees
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
65
diff
changeset
|
82 $::server, |
33
d183277b4d93
refined the output message.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
24
diff
changeset
|
83 $island->id, |
d183277b4d93
refined the output message.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
24
diff
changeset
|
84 $c->cityId |
d183277b4d93
refined the output message.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
24
diff
changeset
|
85 ); |
24 | 86 |
87 printf("%s", $line); | |
10
f590b5ea5e55
fixed bug of sheep.pl
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
8
diff
changeset
|
88 } |
8
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
89 } |
e4b3168d0319
implemented sheep and enemy scripts.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
90 } |
95
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
91 |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
92 __MAIN__: |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
93 |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
94 if($#ARGV != 1) { die("Usage: $0 x y\n"); } |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
95 my ($x, $y) = @ARGV; |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
96 |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
97 listSheeps(Ikariam::User->search_sheeps(($x + 6), ($x - 6), ($y + 6), ($y - 6))); |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
98 # listSheeps(Ikariam::User->search_inactivity(($x + 6), ($x - 6), ($y + 6), ($y - 6))); |
6527b4b20d60
refiend the army score filtering
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
74
diff
changeset
|
99 |