Ejemplo n.º 1
0
 /**
  * Parse the battle's result
  *
  * @return void
  */
 protected function _parseResult()
 {
     // check who has won the fight
     if (preg_match('#' . $this->_regexes["won"] . '#i', $this->_source)) {
         if (preg_match('#' . $this->_regexes["won_attacker"] . '#i', $this->_source)) {
             $this->_report->setWinner(Default_Model_CombatReport::ATTACKER);
             // the attacker won, get the number of stolen resources
             // De aanvaller heeft het gevecht gewonnen! De aanvaller steelt 26.971 metaal, 16.303 kristal en 11.528 deuterium.
             $regex = $this->_regexes["steals"];
             $matches = array();
             preg_match('#' . $regex . '#si', $this->_source, $matches);
             $this->_report->setLoot((double) str_replace('.', '', $matches[1]), (double) str_replace('.', '', $matches[2]), (double) str_replace('.', '', $matches[3]));
         } else {
             $this->_report->setWinner(Default_Model_CombatReport::DEFENDER);
         }
     } else {
         $this->_report->setWinner(Default_Model_CombatReport::DRAW);
     }
     // get the attacker's losses
     $matches = array();
     preg_match('#' . $this->_regexes["lost_attacker"] . '#i', $this->_source, $matches);
     $this->_report->setLossesAttacker((double) str_replace('.', '', $matches[1]));
     // get the defender's losses
     $matches = array();
     preg_match('#' . $this->_regexes["lost_defender"] . '#i', $this->_source, $matches);
     $this->_report->setLossesDefender((double) str_replace('.', '', $matches[1]));
     // get the debris
     $matches = array();
     preg_match('#' . $this->_regexes["debris"] . '#i', $this->_source, $matches);
     $this->_report->setDebris((double) str_replace('.', '', $matches[1]), (double) str_replace('.', '', $matches[2]));
     // moonchance
     $matches = array();
     if (preg_match('#' . $this->_regexes["moon_chance"] . '#i', $this->_source, $matches)) {
         $this->_report->setMoonChance((double) str_replace('.', '', $matches[1]));
     }
     // moon creation
     // De enorme hoeveelheden van rondzwevende metaal- en kristaldeeltjes trekken elkaar aan
     // en vormen langzaam een maan, in een baan rond de planeet.
     $regex = $this->_regexes["moon"];
     $matches = array();
     if (preg_match("#{$regex}#i", $this->_source, $matches)) {
         $this->_report->setMoonGiven(true);
     } else {
         $this->_report->setMoonGiven(false);
     }
 }
Ejemplo n.º 2
0
 /**
  * Parse the battle's result
  *
  * @return void
  */
 protected function _parseResult()
 {
     // check who has won the fight
     if (preg_match('#gewonnen#i', $this->_source)) {
         if (preg_match('#aanvaller heeft het gevecht#i', $this->_source)) {
             $this->_report->setWinner(Default_Model_CombatReport::ATTACKER);
             // the attacker won, get the number of stolen resources
             // De aanvaller heeft het gevecht gewonnen! De aanvaller steelt 26.971 metaal, 16.303 kristal en 11.528 deuterium.
             $regex = 'De aanvaller steelt\\s*?([0-9.]*) metaal, ([0-9.]*) kristal en ([0-9.]*) deuterium';
             $matches = array();
             preg_match('#' . $regex . '#si', $this->_source, $matches);
             $this->_report->setLoot((int) str_replace('.', '', $matches[1]), (int) str_replace('.', '', $matches[2]), (int) str_replace('.', '', $matches[3]));
         } else {
             $this->_report->setWinner(Default_Model_CombatReport::DEFENDER);
         }
     } else {
         $this->_report->setWinner(Default_Model_CombatReport::DRAW);
     }
     // get the attacker's losses
     $matches = array();
     preg_match('#De aanvaller heeft een totaal van ([0-9.]*) eenheden verloren.#i', $this->_source, $matches);
     $this->_report->setLossesAttacker((int) str_replace('.', '', $matches[1]));
     // get the defender's losses
     $matches = array();
     preg_match('#De verdediger heeft een totaal van ([0-9.]*) eenheden verloren.#i', $this->_source, $matches);
     $this->_report->setLossesDefender((int) str_replace('.', '', $matches[1]));
     // get the debris
     $matches = array();
     preg_match('#in de ruimte zweven nu ([0-9.]*) Metaal en ([0-9.]*) Kristal.#i', $this->_source, $matches);
     $this->_report->setDebris((int) str_replace('.', '', $matches[1]), (int) str_replace('.', '', $matches[2]));
     // moonchance
     $matches = array();
     if (preg_match('#De kans dat een maan ontstaat uit het puin is ([0-9]{1,2})#i', $this->_source, $matches)) {
         $this->_report->setMoonChance((int) str_replace('.', '', $matches[1]));
     }
     // moon creation
     // De enorme hoeveelheden van rondzwevende metaal- en kristaldeeltjes trekken elkaar aan
     // en vormen langzaam een maan, in een baan rond de planeet.
     $regex = 'De enorme hoeveelheden van rondzwevende metaal- en kristaldeeltjes trekken elkaar aan ' . 'en vormen langzaam een maan, in een baan rond de planeet.';
     $matches = array();
     if (preg_match("#{$regex}#i", $this->_source, $matches)) {
         $this->_report->setMoonGiven(true);
     } else {
         $this->_report->setMoonGiven(false);
     }
 }
Ejemplo n.º 3
0
 /**
  * Parse the battle's result
  *
  * @return void
  */
 protected function _parseResult()
 {
     // check who has won the fight
     if (preg_match('#has won the battle#i', $this->_source)) {
         if (preg_match('#attacker has won the battle#i', $this->_source)) {
             $this->_report->setWinner(Default_Model_CombatReport::ATTACKER);
             // the attacker won, get the number of stolen resources
             // The attacker has won the battle! He captured 67.585 metal, 36.070 crystal and 10.421 deuterium.
             $regex = 'He captured\\s*?([0-9.]*) metal, ([0-9.]*) crystal and ([0-9.]*) deuterium';
             $matches = array();
             preg_match('#' . $regex . '#si', $this->_source, $matches);
             $this->_report->setLoot((int) str_replace('.', '', $matches[1]), (int) str_replace('.', '', $matches[2]), (int) str_replace('.', '', $matches[3]));
         } else {
             $this->_report->setWinner(Default_Model_CombatReport::DEFENDER);
         }
     } else {
         $this->_report->setWinner(Default_Model_CombatReport::DRAW);
     }
     // get the attacker's losses
     $matches = array();
     preg_match('#The attacker lost a total of ([0-9.]*) units.#i', $this->_source, $matches);
     $this->_report->setLossesAttacker((int) str_replace('.', '', $matches[1]));
     // get the defender's losses
     $matches = array();
     preg_match('#The defender lost a total of ([0-9.]*) units.#i', $this->_source, $matches);
     $this->_report->setLossesDefender((int) str_replace('.', '', $matches[1]));
     // get the debris
     $matches = array();
     preg_match('#At these space coordinates now float ([0-9.]*) metal and ([0-9.]*) crystal.#i', $this->_source, $matches);
     $this->_report->setDebris((int) str_replace('.', '', $matches[1]), (int) str_replace('.', '', $matches[2]));
     // moonchance
     $matches = array();
     if (preg_match('#The chance for a moon to be created is ([0-9]{1,2})#i', $this->_source, $matches)) {
         $this->_report->setMoonChance((int) str_replace('.', '', $matches[1]));
     }
     // moon creation
     // The enormous amounts of free metal and crystal draw together and form a moon around the planet.
     $regex = 'form a moon around the planet.';
     $matches = array();
     if (preg_match("#{$regex}#i", $this->_source, $matches)) {
         $this->_report->setMoonGiven(true);
     } else {
         $this->_report->setMoonGiven(false);
     }
 }