view scan.pl @ 1:f9eac5385dc0

added viewWorldMap
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Tue, 07 Oct 2008 22:56:12 +0800
parents abaee7064429
children 0fb73a7a0b94
line wrap: on
line source

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

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);

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};
        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");

            $c->update();
        } else {
            Ikariam::Cities->insert($city);
        }
    }
}


# TODO
# $i->worldmap($x, $y);
# http://s2.ikariam.tw/index.php?view=worldmap_iso
# xajax getMapData
# xajaxargs[]   54
# xajaxargs[]   30
# xajaxr        1223302744553
# $i->getAcount() account database.

# 經濟, 軍事
# http://s2.ikariam.tw/index.php
# view	highscore
# highscoreType	score
# offset	-1
# searchUser	chihchun

# $i->getCityInfo();