Mercurial > eagle-eye
diff scan.pl @ 2:0fb73a7a0b94
ok, we done basic island scanning functions.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Tue, 07 Oct 2008 23:22:09 +0800 |
parents | f9eac5385dc0 |
children | dbb97c4265ba |
line wrap: on
line diff
--- a/scan.pl Tue Oct 07 22:56:12 2008 +0800 +++ b/scan.pl Tue Oct 07 23:22:09 2008 +0800 @@ -4,19 +4,16 @@ package main; -use Class::DBI::AutoLoader ( - dsn => 'dbi:SQLite:dbname=ikariam.sqlite', - options => { RaiseError => 1 }, - tables => ['cities', 'islands'], - use_base => 'Class::DBI::SQLite', - namespace => 'Ikariam', -); - my $i = new Ikariam("s2.ikariam.tw", "chihchun", "c795d57d"); $i->login; -# my @islands = $i->viewHomeMap(); -# my @islands = $i->viewWorldMap(89, 60); -my @islands = $i->viewWorldMap(50, 34); + +my @islands; +if($#ARGV >= 2) { + @islands = $i->viewWorldMap($ARGV[0], $ARGV[1]); +} else { + @islands = $i->viewHomeMap(); +} +# my @islands = $i->viewWorldMap(50, 34); foreach my $island (@islands) { @@ -34,20 +31,21 @@ foreach my $city (@cities) { $city->{island} = $island->{id}; - printf("checking city %d\n", $city->{cityId}); if(my $c = Ikariam::Cities->retrieve($city->{cityId})) { - foreach my $i (keys(%$city)) - { - eval($c->$i($city->{$i})); - printf("%s %s ", $i, $city->{$i}); - } - print ("\n"); + #foreach my $i (keys(%$city)) + #{ + # eval($c->$i($city->{$i})); + # printf("%s %s ", $i, $city->{$i}); + #} + #print ("\n"); + $c->autoupdate(1); $c->update(); } else { Ikariam::Cities->insert($city); } + printf("city %d %s saved\n", $city->{cityId}, $city->{cityname}); } }