Mercurial > eagle-eye
changeset 362:7f38a5cb769e
dirtry trick
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Mon, 23 Feb 2009 16:26:47 +0800 |
parents | 81a2aeaf6bf7 |
children | 3b2658751efa |
files | disturb.pl |
diffstat | 1 files changed, 49 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/disturb.pl Mon Feb 23 16:26:47 2009 +0800 @@ -0,0 +1,49 @@ +#!/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; + +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'))); + + # Create a new one. + $ikariam->changeCity($myCity); + $ikariam->blockadeCity($blockadeCity, { + blockadeDuration => 8*60*60, + cargo_fleet_211 => 1, # Flamethrower + }); + $ikariam->logout; + + sleep($travelTime*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); +}