Mercurial > eagle-eye
annotate freeland.pl @ 357:f9a6b226fb79
capture scores names nothing, fixed the risk of spy
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Sun, 15 Feb 2009 15:00:09 +0800 |
parents | a9847bf80058 |
children |
rev | line source |
---|---|
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
1 #!/usr/bin/perl |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
2 use strict; |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
3 use Ikariam; |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
4 use Data::Dumper; |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
5 |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
6 package main; |
85
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
7 my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; |
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
8 my @wonderText = qw/NULL 赫菲斯拓斯的熔爐 蓋亞的神殿 狄奧尼索斯的花園 雅典娜的神殿 赫秘士的神殿 阿瑞斯的要塞 波賽頓的神殿 克羅瑟斯的神殿/; |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
9 |
181
dba0543daf36
now, you can assign tradegood for search freeland
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
93
diff
changeset
|
10 if($#ARGV != 2) { |
dba0543daf36
now, you can assign tradegood for search freeland
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
93
diff
changeset
|
11 die("Usage: $0 x y tradegood (1 葡萄酒, 2 大理石, 3 水晶, 4 硫磺/)\n"); |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
12 } |
181
dba0543daf36
now, you can assign tradegood for search freeland
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
93
diff
changeset
|
13 my ($x, $y, $tradegood) = @ARGV; |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
14 |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
15 my @location = (($x + 6), ($x - 6), ($y + 6), ($y - 6)); |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
16 |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
17 # 找空位 |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
18 Ikariam::Cities->set_sql(lamers => qq { |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
19 SELECT cities.cityId |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
20 FROM user, cities |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
21 WHERE user.id == cities.user |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
22 AND user.score <= 1000 |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
23 AND cities.status != 'v' |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
24 AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? AND tradegood == 2) |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
25 } |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
26 ); |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
27 |
85
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
28 # |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
29 my @islands = Ikariam::Island->retrieve_from_sql(qq{ |
181
dba0543daf36
now, you can assign tradegood for search freeland
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
93
diff
changeset
|
30 tradegood == $tradegood |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
31 AND people < 16 |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
32 AND x <= $location[0] |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
33 AND x >= $location[1] |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
34 AND y <= $location[2] |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
35 AND y >= $location[3] |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
36 }); |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
37 |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
38 if($#islands == -1) { |
279
a9847bf80058
refined coding style
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
181
diff
changeset
|
39 my @cities = Ikariam::Cities->search_lamers(@location); |
a9847bf80058
refined coding style
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
181
diff
changeset
|
40 foreach my $city (@cities) { |
a9847bf80058
refined coding style
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
181
diff
changeset
|
41 my $island = Ikariam::Island->retrieve($city->island); |
a9847bf80058
refined coding style
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
181
diff
changeset
|
42 my $user = Ikariam::User->retrieve($city->user); |
a9847bf80058
refined coding style
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
181
diff
changeset
|
43 printf("%s (%d) \"%s\" %d [%d,%d] http://%s/index.php?view=island&id=%d&selectCity=%d\n", |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
44 $user->name, $user->score, |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
45 $city->cityname, $city->citylevel, |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
46 $island->x, $island->y, |
85
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
47 $::server, |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
48 $island->id, |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
49 $city->cityId |
279
a9847bf80058
refined coding style
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
181
diff
changeset
|
50 ); |
a9847bf80058
refined coding style
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
181
diff
changeset
|
51 } |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
52 } else { |
85
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
53 # 依照距離列表 |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
54 foreach my $island (@islands) |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
55 { |
85
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
56 printf("%d [%d:%d] %s %s http://%s/index.php?view=island&id=%d%s\n", |
279
a9847bf80058
refined coding style
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
181
diff
changeset
|
57 (abs($x-$island->x) + abs($y-$island->y)), # minutes ? |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
58 $island->x, $island->y, |
85
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
59 $tradegoodText[$island->tradegood], |
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
60 $wonderText[$island->wonder], |
f25d13153501
fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
32
diff
changeset
|
61 $::server, |
32
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
62 $island->id, |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
63 ); |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
64 } |
b18369979b58
looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
65 } |