/** * @param string $type * @param array $data * @return CombatReport|SpyReport|HarvestReport|SpyReport */ private function getReport($type, $data) { if ($data !== false) { switch ($type) { case OGameApi::TYPE_COMBATREPORT: return CombatReport::createCombatReport($data); case OGameApi::TYPE_HARVESTREPORT: return HarvestReport::createHarvestReport($data); case OGameApi::TYPE_MISSILEREPORT: return MissileReport::createMissileReport($data); case OGameApi::TYPE_SPYREPORT: return SpyReport::createSpyReport($data); default: } } return false; }
/** * @param CombatReport $raid * @return boolean */ public function addRaid(CombatReport $raid) { if ($raid->getPlanet()->getCoordinates() !== $this->getPlanet()->getCoordinates()) { return false; } $this->raids[] = $raid; return true; }
/** * @param CombatReport $combatreport * @param integer $startRound * @param integer $endRound * @throws Exception * @return CombatParty[] */ public static function calculate($combatreport, $startRound, $endRound) { //TODO:: Throw decent exeption if ($endRound < $startRound) { throw new Exception('CombatReport_Result: Your starting round should be greater than your ending round.'); } if ($endRound > 6) { throw new Exception('CombatReport_Result: OGame has a maximum of 6 rounds.'); } if ($startRound === 0) { $startAttackers = $combatreport->getAttackerParty()->getPlayers(); $startDefenders = $combatreport->getDefenderParty()->getPlayers(); } else { $startAttackers = $combatreport->getRound($startRound)->getAttackersDetails(); $startDefenders = $combatreport->getRound($startRound)->getDefendersDetails(); } if ($endRound === 0) { $endAttackers = $combatreport->getAttackerParty()->getPlayers(); $endDefenders = $combatreport->getDefenderParty()->getPlayers(); } else { $endAttackers = $combatreport->getRound($endRound)->getAttackersDetails(); $endDefenders = $combatreport->getRound($endRound)->getDefendersDetails(); } $self = new self(); $self->setAttackers(self::getFleetDifferences($startAttackers, $endAttackers, clone $combatreport->getAttackerParty())); $self->setDefenders(self::getFleetDifferences($startDefenders, $endDefenders, clone $combatreport->getDefenderParty())); return $self; }
/** * @return CombatResult_RoundDifference */ public function getFinalResult() { return $this->getRoundDifference(0, $this->combatreport->getRoundCount()); }
/** * @param string $dataUrl */ public function getCombatReport($dataUrl) { $data = $this->getData($dataUrl); return $data === false ? $data : CombatReport::createCombatReport($data['RESULT_DATA']); }