comparison Ikariam.pm @ 129:3756298f8e4b

fixed the island and city id in the military reports.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Fri, 31 Oct 2008 01:53:57 +0800
parents 4374173bab47
children bfa78302cf09
comparison
equal deleted inserted replaced
126:3196b1f5dc13 129:3756298f8e4b
576 576
577 $report{attacker} = $extractor->find('//div[@id="troopsReport"]//table[@id="result"]//th[@class="attackers"]'); 577 $report{attacker} = $extractor->find('//div[@id="troopsReport"]//table[@id="result"]//th[@class="attackers"]');
578 $report{defender} = $extractor->find('//div[@id="troopsReport"]//table[@id="result"]//th[@class="defenders"]'); 578 $report{defender} = $extractor->find('//div[@id="troopsReport"]//table[@id="result"]//th[@class="defenders"]');
579 $report{winner} = $extractor->find('//div[@id="troopsReport"]//table[@id="result"]//td[@class="winner"]'); 579 $report{winner} = $extractor->find('//div[@id="troopsReport"]//table[@id="result"]//td[@class="winner"]');
580 580
581 $report{targetCity} = $extractor->find('//div[@id="troopsReport"]/div/h3/a/text()'); 581 # $report{targetCity} = $extractor->find('//div[@id="troopsReport"]/div/h3/a/text()');
582 my $href = $extractor->find('//div[@id="troopsReport"]/div/h3/a/@href'); 582 # my $href = $extractor->find('//div[@id="troopsReport"]/div/h3/a/@href');
583 $report{targetCity} = $extractor->find('//td[@class="battle"]/a/text()');
584 my $href = $extractor->find('//td[@class="battle"]/a/@href');
583 if($href =~ /index\.php\?view=island&id=(\d+)&selectCity=(\d+)/) { 585 if($href =~ /index\.php\?view=island&id=(\d+)&selectCity=(\d+)/) {
584 $report{island} = $1; 586 $report{island} = $1;
585 $report{city} = $2; 587 $report{city} = $2;
588 } else {
589 die ($href);
586 } 590 }
587 $report{gold} = $extractor->find('//div[@id="troopsReport"]//ul[@class="resources"]/li[@class="gold"]'); 591 $report{gold} = $extractor->find('//div[@id="troopsReport"]//ul[@class="resources"]/li[@class="gold"]');
588 $report{wood} = $extractor->find('//div[@id="troopsReport"]//ul[@class="resources"]/li[@class="wood"]'); 592 $report{wood} = $extractor->find('//div[@id="troopsReport"]//ul[@class="resources"]/li[@class="wood"]');
589 $report{crystal} = $extractor->find('//div[@id="troopsReport"]//ul[@class="resources"]/li[@class="glass"]'); 593 $report{crystal} = $extractor->find('//div[@id="troopsReport"]//ul[@class="resources"]/li[@class="glass"]');
590 $report{wine} = $extractor->find('//div[@id="troopsReport"]//ul[@class="resources"]/li[@class="wine"]'); 594 $report{wine} = $extractor->find('//div[@id="troopsReport"]//ul[@class="resources"]/li[@class="wine"]');
615 my $href = $trExtractor->find('//td/a/@href'); 619 my $href = $trExtractor->find('//td/a/@href');
616 if($href =~ /index.php\?view=militaryAdvisorReportView&combatId=(\d+)/) { 620 if($href =~ /index.php\?view=militaryAdvisorReportView&combatId=(\d+)/) {
617 my $report = Ikariam::Report->retrieve($1); 621 my $report = Ikariam::Report->retrieve($1);
618 if(!$report) { 622 if(!$report) {
619 my $report_hash = $self->checkMilitaryAdvisorReportView($1); 623 my $report_hash = $self->checkMilitaryAdvisorReportView($1);
620 $report = Ikariam::Report->insert($report_hash); 624 if(defined($report_hash)) {
621 625 $report = Ikariam::Report->insert($report_hash);
622 if($date =~ /(\d+)\.(\d+)\. (\d+):(\d+)/) { 626
623 my $unixtime = mktime (0, $4, $3, $1, ($2-1), '108'); 627 if($date =~ /(\d+)\.(\d+)\. (\d+):(\d+)/) {
624 $report->set('date', $unixtime); 628 my $unixtime = mktime (0, $4, $3, $1, ($2-1), '108');
629 $report->set('date', $unixtime);
630 }
631 $report->set('time', time);
632
633 $report->update();
625 } 634 }
626 $report->set('time', time);
627
628 $report->update();
629 } else { 635 } else {
636 # we have found the report we like to know, exit the function.
630 return; 637 return;
631 } 638 }
632 } else { 639 } else {
640 # there is not report yet.
633 return; 641 return;
634 } 642 }
635 } 643 }
636 644
637 my @moreCombats = $extractor->find('//div[@id="troopsOverview"]//table/tr[position()>10]//a/@href'); 645 my @moreCombats = $extractor->find('//div[@id="troopsOverview"]//table/tr[position()>10]//a/@href');