Mercurial > eagle-eye
comparison scores.pl @ 8:e4b3168d0319
implemented sheep and enemy scripts.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Wed, 08 Oct 2008 04:23:01 +0800 |
parents | 2040ccc95670 |
children | ae412d1f7761 |
comparison
equal
deleted
inserted
replaced
7:2040ccc95670 | 8:e4b3168d0319 |
---|---|
6 package main; | 6 package main; |
7 | 7 |
8 sub saveUser | 8 sub saveUser |
9 { | 9 { |
10 my $users = shift; | 10 my $users = shift; |
11 | |
12 my $u; | |
11 foreach my $user (values(%{$users})) | 13 foreach my $user (values(%{$users})) |
12 { | 14 { |
15 next if($u == $user->{'id'}); $u = $user->{'id'}; | |
16 | |
13 printf("Saving %s\n", $user->{'name'}); | 17 printf("Saving %s\n", $user->{'name'}); |
14 if(my $c = Ikariam::Users->retrieve($user->{id})) | 18 if(my $c = Ikariam::User->retrieve($user->{id})) |
15 { | 19 { |
16 foreach my $i (keys(%$user)) { | 20 foreach my $i (keys(%$user)) { |
17 eval($c->$i($user->{$i})); | 21 eval($c->$i($user->{$i})); |
18 } | 22 } |
19 $c->autoupdate(1); | 23 $c->autoupdate(1); |
20 $c->update(); | 24 $c->update(); |
21 } else { | 25 } else { |
22 Ikariam::Users->insert($user); | 26 Ikariam::User->insert($user); |
23 } | 27 } |
24 } | 28 } |
25 } | 29 } |
26 | 30 |
27 my $i = new Ikariam("s2.ikariam.tw", "chihchun", "c795d57d"); | 31 my $i = new Ikariam("s2.ikariam.tw", "chihchun", "c795d57d"); |
28 $i->login; | |
29 | 32 |
30 if($#ARGV == 0) { | 33 if($#ARGV == 0) { |
34 $i->login; | |
35 | |
31 my $users; | 36 my $users; |
32 foreach my $x (qw/score army_score_main trader_score_secondary/) | 37 foreach my $x (qw/score army_score_main trader_score_secondary/) |
33 { | 38 { |
34 $users = $i->viewScore($x, $ARGV[0], 0); | 39 $users = $i->viewScore($x, $ARGV[0], 0); |
35 saveUser($users); | 40 saveUser($users); |
36 } | 41 } |
37 } elsif ($#ARGV == 1) { | 42 } elsif ($#ARGV == 1) { |
43 $i->login; | |
44 | |
38 # search the islands and cities nearby | 45 # search the islands and cities nearby |
39 my ($x, $y) = @ARGV; | 46 my ($x, $y) = @ARGV; |
40 my $offset = 5; | 47 my $offset = 5; |
41 | 48 |
42 Ikariam::Island->has_many(cities => 'Ikariam::Cities'); | 49 Ikariam::Island->has_many(cities => 'Ikariam::Cities'); |
67 } | 74 } |
68 } | 75 } |
69 } else { | 76 } else { |
70 # my $users = $i->viewScore('army_score_main'); | 77 # my $users = $i->viewScore('army_score_main'); |
71 # saveUser($users); | 78 # saveUser($users); |
72 die("Usage: $0 nickname\n"); | 79 die("Usage: $0 nickname\nUsage: $0 x y"); |
73 } | 80 } |
74 | 81 |
75 # highscoreType | 82 # highscoreType |
76 # <option value="score">總積分</option> | 83 # <option value="score">總積分</option> |
77 # <option value="building_score_main">建築大師</option> | 84 # <option value="building_score_main">建築大師</option> |