Mercurial > eagle-eye
annotate flash.pl @ 374:e551351b18de
updated for timestamp of scores information
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Tue, 14 Apr 2009 17:01:17 +0800 |
parents | 0522468991c1 |
children |
rev | line source |
---|---|
371
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
1 #!/usr/bin/perl |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
2 |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
3 use strict; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
4 use Ikariam; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
5 use Ikariam::CitiesRules; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
6 use Data::Dumper; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
7 use Decision::ParseTree q{ParseTree}; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
8 use YAML qw/LoadFile Dump DumpFile/; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
9 |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
10 package main; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
11 my $cityId = 95780; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
12 my $cities = {}; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
13 |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
14 our $i = new Ikariam($::server, $::user, $::pass); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
15 $i->login; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
16 $i->changeCity($cityId); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
17 $cities->{$cityId} = $i->checkCity($cityId); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
18 |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
19 # Genereic rules for both overall and city level arranagement. |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
20 my $rules = Ikariam::CitiesRules->new($i); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
21 my $tree = LoadFile('flash-city.yaml'); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
22 $cities->{$cityId}->{parse_path} = []; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
23 $cities->{$cityId}->{parse_answer} = undef; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
24 if (my $action = ParseTree($tree, $rules, $cities->{$cityId})) { |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
25 triggerAction($action, $cityId); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
26 } |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
27 |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
28 $i->logout; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
29 |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
30 sub triggerAction { |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
31 my ($action, $cityId) = @_; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
32 |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
33 my ($func, $param) = split(/_/,$action); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
34 printf('$i->%s("%s", %s);'. "\n", $func, $param, $cityId); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
35 eval(sprintf('$i->%s("%s", %s);', $func, $param, $cityId)); |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
36 warn $@ if $@; |
0522468991c1
added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff
changeset
|
37 } |