Mercurial > eagle-eye
view disturb.pl @ 373:dd3d76f43999
update script for collecting ally information.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Tue, 14 Apr 2009 17:00:40 +0800 |
parents | 9f19fe8d189c |
children |
line wrap: on
line source
#!/usr/bin/perl use strict; use Ikariam; use Data::Dumper; package main; my $ikariam = new Ikariam($::server, $::user, $::pass); if($#ARGV != 2) { die("Usage: $0 blockadeCity myCity travelTime\n"); } my ($blockadeCity, $myCity, $travelTime) = @ARGV; $travelTime = ($travelTime - 10); LOOP: while(1) { $ikariam->login; # delete the old event, and launch a new one. my $res = $ikariam->{mech}->get(sprintf('http://%s/index.php?view=militaryAdvisorMilitaryMovements', $::server)); my $extractor = new Ikariam::Extractor(content => $res->content); my $result = $extractor->{doc}->find(sprintf('//table[@class="locationEvents"]//tr[position() > 1]', $_)); foreach my $div ( @$result ) { my $extractor = new Ikariam::Extractor(content => $div->toString(1)); my $f = $extractor->find('//td[4]/a/@href'); my $t = $extractor->find('//td[8]/a/@href'); my $from_city = $1 if($f =~ /\?view=island&cityId=(\d+)/); my $to_city = $1 if($t =~ /\?view=island&cityId=(\d+)/); if($from_city == $myCity && $to_city == $blockadeCity) { # Cancel the last attack $ikariam->{mech}->get(sprintf("http://%s/index.php%s", $::server, $extractor->find('//td[9]/a/@href'))); $ikariam->logout; sleep(60); # Create a new one. $ikariam->login; $ikariam->changeCity($myCity); $ikariam->blockadeCity($blockadeCity, { blockadeDuration => 8*60*60, cargo_fleet_211 => 1, # Flamethrower }); $ikariam->logout; sleep(($travelTime-1)*60); next LOOP; } } $ikariam->login; $ikariam->changeCity($myCity); $ikariam->blockadeCity($blockadeCity, { blockadeDuration => 8*60*60, cargo_fleet_211 => 1, # Flamethrower }); $ikariam->logout; sleep($travelTime*60); }