예제 #1
0
 /**
  * Parse a crash report
  *
  * @param string $source
  * @param boolean $mergeFleets
  *
  * @return Default_Model_CombatReport
  */
 public function parse($source)
 {
     $this->_source = stristr($source, 'De volgende vloten kwamen elkaar tegen op');
     // check the CR
     if (false === $this->_source) {
         throw new Exception('Bad CR');
     }
     $this->_report = new Default_Model_CombatReport();
     $matches = array();
     if (preg_match('#^De volgende vloten kwamen elkaar tegen op \\(([0-9]{2}).([0-9]{2}).([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2})\\):#i', $this->_source, $matches)) {
         $this->_report->setTime(new DateTime($matches[3] . ":" . $matches[2] . ":" . $matches[1] . " " . $matches[4] . ":" . $matches[5] . ":" . $matches[6]));
     } else {
         throw new Exception('Bad CR');
     }
     $this->_source = substr($this->_source, strlen($matches[0]));
     while (preg_match('#(Aanvaller|Verdediger) (.*) \\[([0-9]:[0-9]{1,3}:[0-9]{1,2})\\]#i', $this->_source)) {
         $this->_report->addRound($this->_parseRound());
     }
     $this->_parseResult();
     // check if we should merge multiple fleets of the same attacker or defender into one
     if ($this->getMergeFleets()) {
         $this->_mergeFleets();
     }
     return $this->_report;
 }