Beispiel #1
0
 /**
  * Merge fleets together.
  *
  * @return void
  */
 private function _mergeFleets()
 {
     foreach ($this->_report->getRounds() as $round) {
         // first merge the fleets of the attackers
         $attackers = array();
         foreach ($round->getAttackers() as $fleet) {
             $player = $fleet->getPlayer();
             if (isset($attackers[$player])) {
                 // merge this fleet into the previous one
                 $attackers[$player] = $this->_mergeFleet($attackers[$player], $fleet);
             } else {
                 // we haven't seen this attacker before, create a new slot
                 $attackers[$player] = $fleet;
             }
         }
         $round->setAttackers(array_values($attackers));
         unset($attackers);
         // now merge the fleets of the defenders
         $defenders = array();
         foreach ($round->getDefenders() as $fleet) {
             $player = $fleet->getPlayer();
             if (isset($defenders[$player])) {
                 // merge this fleet into the previous one
                 $defenders[$player] = $this->_mergeFleet($defenders[$player], $fleet);
             } else {
                 // we haven't seen this attacker before, create a new slot
                 $defenders[$player] = $fleet;
             }
         }
         $round->setDefenders(array_values($defenders));
     }
 }
 /**
  * Render the result of the battle.
  *
  * @return string
  */
 public function _renderResult()
 {
     $this->getView()->totalDebris = 0;
     foreach ($this->_report->getHarvestReports() as $hr) {
         $this->getView()->totalDebris += $hr->getMetal() + $hr->getCrystal();
     }
     $this->getView()->totalRaids = $this->_report->getMetal() + $this->_report->getCrystal() + $this->_report->getDeuterium();
     foreach ($this->_report->getRaids() as $raid) {
         $this->getView()->totalRaids += $raid->getMetal() + $raid->getCrystal() + $raid->getDeuterium();
     }
     return $this->_renderWinnerLoot() . $this->_renderLossesMoon() . $this->_renderDebris() . $this->_renderSummary();
 }
Beispiel #3
0
 /**
  * @return string
  */
 public function _renderResult()
 {
     $this->data->totalDebrisAttackers = 0;
     $this->data->totalDebrisDefenders = 0;
     $this->data->raidDeutRes = 0;
     $this->data->totalLossesAttacker = $this->_report->getLossesAttacker();
     $this->data->totalLossesDefender = $this->_report->getLossesDefender();
     //Harvest reports
     foreach ($this->_report->getAttackers()->getHarvestReports() as $hr) {
         $this->data->totalDebrisAttackers += $hr->getMetal() + $hr->getCrystal();
     }
     foreach ($this->_report->getDefenders()->getHarvestReports() as $hr) {
         $this->data->totalDebrisDefenders += $hr->getMetal() + $hr->getCrystal();
     }
     //Raids
     $this->data->totalRaids = $this->_report->getMetal() + $this->_report->getCrystal() + $this->_report->getDeuterium();
     foreach ($this->_report->getRaids() as $raid) {
         $this->data->totalRaids += $raid->getMetal() + $raid->getCrystal() + $raid->getDeuterium();
         $this->data->raidDeutRes += $raid->getDeuterium();
     }
     // Fuel costs
     $this->data->totalFuelAttackers = 0;
     $this->data->totalFuelDefenders = 0;
     if ($this->_report->getAttackers()->getDeuteriumCosts() > 0) {
         foreach ($this->_report->getAttackers()->getDeuteriumCosts() as $fuel) {
             $this->data->totalFuelAttackers += $fuel->getDeuteriumCosts();
         }
     }
     if ($this->_report->getDefenders()->getDeuteriumCosts() > 0) {
         foreach ($this->_report->getDefenders()->getDeuteriumCosts() as $fuel) {
             $this->data->totalFuelDefenders += $fuel->getDeuteriumCosts();
         }
     }
     // calculate the result
     $this->data->attackerResult = $this->data->totalDebrisAttackers + $this->data->totalRaids - $this->data->totalFuelAttackers - $this->data->totalLossesAttacker;
     $this->data->defenderResult = $this->data->totalDebrisDefenders - $this->data->totalFuelDefenders - $this->data->totalLossesDefender;
     return $this->render('winnerloot') . $this->render('lossesmoon') . $this->render('debris') . $this->render('summary');
     //. $this->render('advancedsummary');
 }