Mercurial > eagle-eye
diff flash.pl @ 371:0522468991c1
added flash attacking script.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Tue, 14 Apr 2009 16:59:14 +0800 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flash.pl Tue Apr 14 16:59:14 2009 +0800 @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +use strict; +use Ikariam; +use Ikariam::CitiesRules; +use Data::Dumper; +use Decision::ParseTree q{ParseTree}; +use YAML qw/LoadFile Dump DumpFile/; + +package main; +my $cityId = 95780; +my $cities = {}; + +our $i = new Ikariam($::server, $::user, $::pass); +$i->login; +$i->changeCity($cityId); +$cities->{$cityId} = $i->checkCity($cityId); + +# Genereic rules for both overall and city level arranagement. +my $rules = Ikariam::CitiesRules->new($i); +my $tree = LoadFile('flash-city.yaml'); +$cities->{$cityId}->{parse_path} = []; +$cities->{$cityId}->{parse_answer} = undef; +if (my $action = ParseTree($tree, $rules, $cities->{$cityId})) { + triggerAction($action, $cityId); +} + +$i->logout; + +sub triggerAction { + my ($action, $cityId) = @_; + + my ($func, $param) = split(/_/,$action); + printf('$i->%s("%s", %s);'. "\n", $func, $param, $cityId); + eval(sprintf('$i->%s("%s", %s);', $func, $param, $cityId)); + warn $@ if $@; +}