comparison Ikariam.pm @ 171:2efa901871e5

check peace treaty
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 02 Nov 2008 03:01:24 +0800
parents 637314cc57ed
children 0cfc7a19a4d2
comparison
equal deleted inserted replaced
170:7df753a99926 171:2efa901871e5
439 } 439 }
440 440
441 sub plunderCity { 441 sub plunderCity {
442 my $self = shift; 442 my $self = shift;
443 my $cityId = shift; 443 my $cityId = shift;
444 $self->{mech}->get(sprintf("http://%s/index.php?view=plunder&destinationCityId=%d", $self->{server}, $cityId)); 444 my $res = $self->{mech}->get(sprintf("http://%s/index.php?view=plunder&destinationCityId=%d", $self->{server}, $cityId));
445 $self->{mech}->submit_form( 445
446 form_number => 1, 446 # check peace treaty
447 fields => { 447 my $treaty = Ikariam::Extractor->new(content => $res->content)->find('//div[@class="warning"]');
448 cargo_army_302 => '2', 448 if(!defined($treaty)) {
449 } 449 $self->{mech}->submit_form(
450 ); 450 form_number => 1,
451 fields => {
452 cargo_army_302 => '2',
453 }
454 );
455 } else {
456 warn ($treaty);
457 }
451 } 458 }
452 459
453 sub changeCity { 460 sub changeCity {
454 my $self = shift; 461 my $self = shift;
455 my $cityId = shift; 462 my $cityId = shift;