annotate freeland.pl @ 129:3756298f8e4b

fixed the island and city id in the military reports.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Fri, 31 Oct 2008 01:53:57 +0800
parents 73f0a1cafc23
children dba0543daf36
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
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
10 if($#ARGV != 1) {
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
11 die("Usage: $0 x y\n");
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
12 }
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
13 my ($x, $y) = @ARGV;
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{
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
30 tradegood == 2
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) {
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
39 my @cities = Ikariam::Cities->search_lamers(@location);
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
40 foreach my $city (@cities) {
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
41 my $island = Ikariam::Island->retrieve($city->island);
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
42 my $user = Ikariam::User->retrieve($city->user);
85
f25d13153501 fixed the server name
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents: 32
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
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
50 );
b18369979b58 looking for available land.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
51 }
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",
93
73f0a1cafc23 upgrade townHall first, then the wall.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents: 85
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 }