# HG changeset patch # User "Rex Tsai " # Date 1239699640 -28800 # Node ID dd3d76f43999f9327437c0157dd820abcb7a0bae # Parent 9f19fe8d189c2e9fb08c473616faa62e79fd9c65 update script for collecting ally information. diff -r 9f19fe8d189c -r dd3d76f43999 ally-map.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ally-map.pl Tue Apr 14 17:00:40 2009 +0800 @@ -0,0 +1,79 @@ +#!/usr/bin/perl +use strict; +use Ikariam; +use Data::Dumper; +use List::Util qw[min max]; + +package main; + +# my $users = Ikariam::User->search(ally => 'WMeMe'); + +Ikariam::Cities->set_sql(ally => qq { + SELECT cities.id + FROM island, cities + WHERE cities.island == island.id + AND cities.ally == ? + }); + +Ikariam::Island->has_many(cities => 'Ikariam::Cities'); +Ikariam::Island->set_sql(ally => qq { + SELECT island.id + FROM island, cities + WHERE cities.island == island.id + AND cities.ally == ? + }); + +die("Usage: $0\nUsage: $0 ally\n") unless ($#ARGV == 0); + +my @islands = Ikariam::Island->search_ally($ARGV[0]); +my %maps; + +my $x1 = 99; +my $x2 = 0; +my $y1 = 99; +my $y2 = 0; + +foreach my $island (@islands) +{ + $x1 = min ($x1, $island->x); + $x2 = max ($x2, $island->x); + $y1 = min ($y1, $island->y); + $y2 = max ($y2, $island->y); + + $maps{$island->x}{$island->y}{'id'} = $island->id; + $maps{$island->x}{$island->y}{'density'} += 1; + # printf("[%s,%s]", $island->x, $island->y); +} + +open(OUT, sprintf(">%s-map.html", $ARGV[0])) or die $!; +printf(OUT ""); + +foreach my $y($y1..$y2) +{ + print(OUT ""); + foreach my $x ($x1..$x2) + { + # printf("
o
"); + if(defined($maps{$x}{$y}{'density'})) { + my $c = 255 - (15 * $maps{$x}{$y}{'density'}); + printf(OUT "", + $c, $c, $::server, $maps{$x}{$y}{'id'}, $x, $y, $maps{$x}{$y}{'density'}, $x, $y); + } else { + printf(OUT "", $x, $y); + } + } + print(OUT ""); +} +printf(OUT "
[%d,%d][%d,%d]
"); +close(OUT); diff -r 9f19fe8d189c -r dd3d76f43999 ally.pl --- a/ally.pl Tue Apr 14 17:00:05 2009 +0800 +++ b/ally.pl Tue Apr 14 17:00:40 2009 +0800 @@ -5,14 +5,12 @@ use List::Util qw[min max]; package main; - # my $users = Ikariam::User->search(ally => 'WMeMe'); Ikariam::Cities->set_sql(ally => qq { - SELECT cities.id - FROM island, cities - WHERE cities.island == island.id - AND cities.ally == ? + SELECT cities.cityId + FROM cities + WHERE cities.ally == ? }); Ikariam::Island->has_many(cities => 'Ikariam::Cities'); @@ -25,55 +23,5 @@ die("Usage: $0\nUsage: $0 ally\n") unless ($#ARGV == 0); -my @islands = Ikariam::Island->search_ally($ARGV[0]); -my %maps; - -my $x1 = 99; -my $x2 = 0; -my $y1 = 99; -my $y2 = 0; - -foreach my $island (@islands) -{ - $x1 = min ($x1, $island->x); - $x2 = max ($x2, $island->x); - $y1 = min ($y1, $island->y); - $y2 = max ($y2, $island->y); - - $maps{$island->x}{$island->y}{'id'} = $island->id; - $maps{$island->x}{$island->y}{'density'} += 1; - # printf("[%s,%s]", $island->x, $island->y); -} - -open(OUT, sprintf(">%s-map.html", $ARGV[0])) or die $!; -printf(OUT ""); - -foreach my $y($y1..$y2) -{ - print(OUT ""); - foreach my $x ($x1..$x2) - { - # printf("
o
"); - if(defined($maps{$x}{$y}{'density'})) { - my $c = 255 - (15 * $maps{$x}{$y}{'density'}); - printf(OUT "", - $c, $c, $::server, $maps{$x}{$y}{'id'}, $x, $y, $maps{$x}{$y}{'density'}, $x, $y); - } else { - printf(OUT "", $x, $y); - } - } - print(OUT ""); -} -printf(OUT "
[%d,%d][%d,%d]
"); -close(OUT); +my @cities = Ikariam::Cities->search_ally($ARGV[0]); +print Dumper(@cities);