# HG changeset patch # User "Rex Tsai " # Date 1223659336 -28800 # Node ID b18369979b58aab7d5ebe768754330a53d1a8438 # Parent e992576ac97c35240e020dde8407949bfc4d97e0 looking for available land. diff -r e992576ac97c -r b18369979b58 freeland.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/freeland.pl Sat Oct 11 01:22:16 2008 +0800 @@ -0,0 +1,56 @@ +#!/usr/bin/perl +use strict; +use Ikariam; +use Data::Dumper; + +package main; + +if($#ARGV != 1) { + die("Usage: $0 x y\n"); +} +my ($x, $y) = @ARGV; + +my @location = (($x + 6), ($x - 6), ($y + 6), ($y - 6)); + +# 找空位 +Ikariam::Cities->set_sql(lamers => qq { + SELECT cities.cityId + FROM user, cities + WHERE user.id == cities.user + AND user.score <= 1000 + AND cities.status != 'v' + AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? AND tradegood == 2) + } +); + +my @islands = Ikariam::Island->retrieve_from_sql(qq{ + tradegood == 2 + AND people < 16 + AND x <= $location[0] + AND x >= $location[1] + AND y <= $location[2] + AND y >= $location[3] + }); + +if($#islands == -1) { + my @cities = Ikariam::Cities->search_lamers(@location); + foreach my $city (@cities) { + my $island = Ikariam::Island->retrieve($city->island); + my $user = Ikariam::User->retrieve($city->user); + printf("%s (%d) \"%s\" %d [%d,%d] http://s2.ikariam.tw/index.php?view=island&id=%d&selectCity=%d\n", + $user->name, $user->score, + $city->cityname, $city->citylevel, + $island->x, $island->y, + $island->id, + $city->cityId + ); + } +} else { + foreach my $island (@islands) + { + printf("[%d:%d] http://s2.ikariam.tw/index.php?view=island&id=%d%s\n", + $island->x, $island->y, + $island->id, + ); + } +}