# HG changeset patch # User "Rex Tsai " # Date 1225566084 -28800 # Node ID 2efa901871e539a21d8ae5d72175134256a9aa08 # Parent 7df753a9992643e75c96837c4b2a3c0ce3f538ee check peace treaty diff -r 7df753a99926 -r 2efa901871e5 Ikariam.pm --- a/Ikariam.pm Sun Nov 02 02:23:13 2008 +0800 +++ b/Ikariam.pm Sun Nov 02 03:01:24 2008 +0800 @@ -441,13 +441,20 @@ sub plunderCity { my $self = shift; my $cityId = shift; - $self->{mech}->get(sprintf("http://%s/index.php?view=plunder&destinationCityId=%d", $self->{server}, $cityId)); - $self->{mech}->submit_form( - form_number => 1, - fields => { - cargo_army_302 => '2', - } - ); + my $res = $self->{mech}->get(sprintf("http://%s/index.php?view=plunder&destinationCityId=%d", $self->{server}, $cityId)); + + # check peace treaty + my $treaty = Ikariam::Extractor->new(content => $res->content)->find('//div[@class="warning"]'); + if(!defined($treaty)) { + $self->{mech}->submit_form( + form_number => 1, + fields => { + cargo_army_302 => '2', + } + ); + } else { + warn ($treaty); + } } sub changeCity {