view scan.pl @ 6:2975a94aa7a2

removed test code.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Wed, 08 Oct 2008 01:52:18 +0800
parents dbb97c4265ba
children 2040ccc95670
line wrap: on
line source

#!/usr/bin/perl
use strict;
use Ikariam;

package main;

my $i = new Ikariam("s2.ikariam.tw", "chihchun", "c795d57d");
$i->login;

my @islands;
if($#ARGV >= 1) {
    @islands = $i->viewWorldMap($ARGV[0], $ARGV[1]);
} else {
    @islands = $i->viewHomeMap();
}

foreach my $island (@islands)
{
    printf("checking island %d\n", $island->{id});
    if(my $c = Ikariam::Islands->retrieve($island->{id})) {
        foreach my $i (keys(%$island)) {
            eval($c->$i($island->{$i}));
        }
    } else {
        Ikariam::Islands->insert($island);
    }

    # scanning the island
    my @cities = $i->viewIsland($island->{id});
    foreach my $city (@cities)
    {
        $city->{island} = $island->{id};
        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");

            $c->autoupdate(1);
            $c->update();
        } else {
            Ikariam::Cities->insert($city);
        }
        printf("city %d %s saved\n", $city->{cityId}, $city->{cityname});
    }
}

# $i->getCityInfo();