comparison Ikariam.pm @ 338:824f949bc484

we attack zero army victim every 3 days
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Thu, 12 Feb 2009 03:59:24 +0800
parents 6eac624efc80
children 4bea7db828eb
comparison
equal deleted inserted replaced
337:025a36717f2c 338:824f949bc484
850 my $extractor = new Ikariam::Extractor(content => $res->content); 850 my $extractor = new Ikariam::Extractor(content => $res->content);
851 851
852 $self->{'military'}->{wars} = 0; 852 $self->{'military'}->{wars} = 0;
853 $self->{'military'}->{attack} = 0; 853 $self->{'military'}->{attack} = 0;
854 854
855 # FIXME, we don't if there is a attack.
855 foreach (qw/homeland elsewhere/) { 856 foreach (qw/homeland elsewhere/) {
856 $self->{'military'}->{$_} = (); 857 $self->{'military'}->{$_} = ();
857 my $result = $extractor->{doc}->find(sprintf('//div[@id="%s"]//ul[@id="battleReports"]/li[@class="enroute"]', $_)); 858 my $result = $extractor->{doc}->find(sprintf('//table[@class="locationEvents"]//tr[position() > 1]', $_));
858 foreach my $div ( @$result ) { 859 foreach my $div ( @$result ) {
859 my $extractor = new Ikariam::Extractor(content => $div->toString(1)); 860 my $extractor = new Ikariam::Extractor(content => $div->toString(1));
860 my $f = $extractor->find('//div[@class="report"]/a[1]/@href'); 861 my $f = $extractor->find('//td[4]/a/@href');
861 my $t = $extractor->find('//div[@class="report"]/a[2]/@href'); 862 my $t = $extractor->find('//td[8]/a/@href');
862 $f = $1 if($f =~ /\?view=island&cityId=(\d+)/); 863 $f = $1 if($f =~ /\?view=island&cityId=(\d+)/);
863 $t = $1 if($t =~ /\?view=island&cityId=(\d+)/); 864 $t = $1 if($t =~ /\?view=island&cityId=(\d+)/);
864 865
865 push @{$self->{'military'}->{$_}}, { from => $f, to => $t}; 866 push @{$self->{'military'}->{$_}}, { from => $f, to => $t};
866 if($_ eq 'homeland') { 867
867 $self->{'military'}->{wars}++; 868 # if($_ eq 'homeland') {
868 } else { 869 # $self->{'military'}->{wars}++;
869 $self->{'military'}->{attack}++; 870 # } else {
870 } 871 # $self->{'military'}->{attack}++;
872 # }
871 } 873 }
872 } 874 }
873 } 875 }
874 876
875 sub checkMilitaryAdvisorReportView { 877 sub checkMilitaryAdvisorReportView {