Mercurial > eagle-eye
changeset 18:fd44e3a1f800
fixed the cache.
show tradegoodText of sheeps.
refined enemy.pl
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Wed, 08 Oct 2008 16:10:01 +0800 |
parents | 5ea88404dc74 |
children | 9c52ae71c1cb |
files | enemy.pl scan.pl sheep.pl |
diffstat | 3 files changed, 37 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/enemy.pl Wed Oct 08 15:25:48 2008 +0800 +++ b/enemy.pl Wed Oct 08 16:10:01 2008 +0800 @@ -4,6 +4,8 @@ use Data::Dumper; package main; +my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; +my @wonderText = qw/NULL 赫菲斯拓斯的熔爐 蓋亞的神殿 狄奧尼索斯的花園 雅典娜的神殿 赫秘士的神殿 阿瑞斯的要塞 波賽頓的神殿 克羅瑟斯的神殿/; if($#ARGV != 0) { die("Usage: $0 nickname\n"); @@ -12,8 +14,20 @@ Ikariam::User->has_many(cities => 'Ikariam::Cities'); my ($u) = Ikariam::User->search('name' => $ARGV[0]); if(defined($u)) { - print Dumper($u->_data_hash); - foreach my $c ($u->cities) { - print Dumper($c->_data_hash); + foreach my $i (qw/name score trader_score_secondary army_score_main ally/) { + printf("%s: %s\n", $i, $u->get($i)); + } + printf("\nCities\n"); + # print Dumper($u->_data_hash); + foreach my $city ($u->cities) { + my $island = Ikariam::Island->retrieve($city->island); + printf("Name: %s\n", $city->cityname); + printf("Level: %s\n", $city->citylevel); + printf("Island: %s\n", $island->name); + printf("Location: [%s:%s] http://s2.ikariam.tw/index.php?view=island&id=%s\n", $island->x, $island->y, $island->id); + printf("Tradegood: %s\n", $tradegoodText[$island->tradegood]); + printf("Wonder: %s\n\n", $wonderText[$island->wonder]); + # print Dumper($island->_data_hash); + # print Dumper($city->_data_hash); } }
--- a/scan.pl Wed Oct 08 15:25:48 2008 +0800 +++ b/scan.pl Wed Oct 08 16:10:01 2008 +0800 @@ -80,25 +80,28 @@ die("Usage: $0\nUsage: $0 x y\n"); } -foreach my $island (@islands) +foreach my $h_island (@islands) { - printf("checking island %d\n", $island->{id}); + printf("checking island %d\n", $h_island->{id}); + + my $island; + if($island = Ikariam::Island->retrieve($h_island->{id})) { + foreach my $i (keys(%$h_island)) { + $island->set($i => $h_island->{$i}); + } + } else { + $island = Ikariam::Island->insert($h_island); + } # scanning the island - if($island->{time} < (time - 60*60*12 )) + if($island->time le (time - 60*60*12 )) { - my @cities = $i->viewIsland($island->{id}); - saveCities($island->{id}, @cities); + my @cities = $i->viewIsland($h_island->{id}); + saveCities($h_island->{id}, @cities); + } - $island->{'time'} = time; - if(my $c = Ikariam::Island->retrieve($island->{id})) { - foreach my $i (keys(%$island)) { - eval($c->$i($island->{$i})); - } - } else { - Ikariam::Island->insert($island); - } - } + $island->set('time', time); + $island->update(); } $i->logout; # $i->getCityInfo();
--- a/sheep.pl Wed Oct 08 15:25:48 2008 +0800 +++ b/sheep.pl Wed Oct 08 16:10:01 2008 +0800 @@ -4,6 +4,7 @@ use Data::Dumper; package main; +my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; Ikariam::User->has_many(cities => 'Ikariam::Cities'); Ikariam::User->set_sql(inactivity => qq { @@ -69,8 +70,9 @@ $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],http://s2.ikariam.tw/index.php?view=island&id=%d\n", $c->cityname, $c->citylevel, + 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");