view freeland.pl @ 64:19d2a7b175b3

Load configure data from .eagleeye.pm
author kevin@localhost.localdomain
date Wed, 22 Oct 2008 05:57:19 +0800
parents b18369979b58
children f25d13153501
line wrap: on
line source

#!/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,
        );
    }
}