comparison scan.pl @ 0:abaee7064429

new scanning prototype.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Tue, 07 Oct 2008 22:24:46 +0800
parents
children f9eac5385dc0
comparison
equal deleted inserted replaced
-1:000000000000 0:abaee7064429
1 #!/usr/bin/perl
2 use strict;
3 use Ikariam;
4
5 package main;
6
7 use Class::DBI::AutoLoader (
8 dsn => 'dbi:SQLite:dbname=ikariam.sqlite',
9 options => { RaiseError => 1 },
10 tables => ['cities', 'islands'],
11 use_base => 'Class::DBI::SQLite',
12 namespace => 'Ikariam',
13 );
14
15 my $i = new Ikariam("s2.ikariam.tw", "chihchun", "c795d57d");
16 $i->login;
17 my @islands = $i->viewWorldMap(89, 60);
18
19 foreach my $island (@islands)
20 {
21 printf("checking island %d\n", $island->{id});
22 if(my $c = Ikariam::Islands->retrieve($island->{id})) {
23 foreach my $i (keys(%$island)) {
24 eval($c->$i($island->{$i}));
25 }
26 } else {
27 Ikariam::Islands->insert($island);
28 }
29
30 # scanning the island
31 my @cities = $i->viewIsland($island->{id});
32 foreach my $city (@cities)
33 {
34 $city->{island} = $island->{id};
35 printf("checking city %d\n", $city->{cityId});
36 if(my $c = Ikariam::Cities->retrieve($city->{cityId}))
37 {
38 foreach my $i (keys(%$city))
39 {
40 eval($c->$i($city->{$i}));
41 printf("%s %s ", $i, $city->{$i});
42 }
43 print ("\n");
44
45 $c->update();
46 } else {
47 Ikariam::Cities->insert($city);
48 }
49 }
50 }
51
52
53 # TODO
54 # $i->worldmap($x, $y);
55 # http://s2.ikariam.tw/index.php?view=worldmap_iso
56 # xajax getMapData
57 # xajaxargs[] 54
58 # xajaxargs[] 30
59 # xajaxr 1223302744553
60 # $i->getAcount() account database.
61
62 # 經濟, 軍事
63 # http://s2.ikariam.tw/index.php
64 # view highscore
65 # highscoreType score
66 # offset -1
67 # searchUser chihchun
68
69 # $i->getCityInfo();