Mercurial > eagle-eye
view sheep.pl @ 22:552528bb4917
refined the cache timeout is 12 hours.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Wed, 08 Oct 2008 19:27:54 +0800 |
parents | fd44e3a1f800 |
children | 54ab0becd730 |
line wrap: on
line source
#!/usr/bin/perl use strict; use Ikariam; use Data::Dumper; package main; my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; Ikariam::User->has_many(cities => 'Ikariam::Cities'); Ikariam::User->set_sql(inactivity => qq { SELECT user.id FROM user, cities, island WHERE user.id == cities.user AND cities.island == island.id AND island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? AND cities.status = 'i' } ); Ikariam::User->set_sql(sheeps => qq { SELECT user.id FROM user, cities, island WHERE user.id == cities.user AND cities.island == island.id AND island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? AND user.score >= 500 AND user.army_score_main <= 25 } ); if($#ARGV != 1) { die("Usage: $0 x y\n"); } my ($x, $y) = @ARGV; listSheeps(Ikariam::User->search_sheeps(($x + 6), ($x - 6), ($y + 6), ($y - 6))); # listSheeps(Ikariam::User->search_inactivity(($x + 6), ($x - 6), ($y + 6), ($y - 6))); sub listSheeps { my @sheeps = @_; my $s; foreach my $sheep (sort (@sheeps)) { # avoid duplicate next if($sheep->id == $s); $s = $sheep->id; # 查聯盟數量 my $members = 1; unless ($sheep->allyId == '0') { $members = Ikariam::User->search(allyId => $sheep->allyId)->count(); } foreach my $c ($sheep->cities) { # 假期模式 next if($c->status eq 'v'); unless($c->status eq 'i') { next if($members > 3); } printf("%d %s %d,%d,%s of %s (%d),", $sheep->trader_score_secondary, $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally, $members); my $island = Ikariam::Island->retrieve($c->island); printf("%s %d [%d,%d] %s http://s2.ikariam.tw/index.php?view=island&id=%d\n", $c->cityname, $c->citylevel, $island->x, $island->y, $tradegoodText[$island->tradegood], $island->id); } printf("\n"); } } # find_or_create