/** * Cancels this flight. */ public function cancel() { // delete events $eventIDsStr = ""; $data = $this->getData(); foreach ($data as $key => $eventID) { if (strpos($key, 'EventID') !== false && $key !== 'returnEventID' && $eventID != 0) { if (!empty($eventIDsStr)) { $eventIDsStr .= ","; } $eventIDsStr .= $eventID; } } if (empty($eventIDsStr)) { return; } WOTEventEditor::deleteEvents($eventIDsStr); // calc flown time $returnTime = $this->getCancelDuration() + microtime(true); $returnEvent = new WOTEventEditor($this->returnEventID); $returnEvent->changeTime($returnTime); $this->update(array('impactTime' => 0, 'returnTime' => $returnTime)); EventHandler::fireAction($this, 'cancel'); // TODO: integrate this in wcf eventhandler cancel@FleetEditor if ($this->missionID == 11) { $leaderFleet = $this->getNavalFormation()->cancelFleet($this->fleetID); // update ovents if ($leaderFleet !== null) { FleetOvent::create($leaderFleet, true, false, true); } } // TODO: integrate this in wcf eventhandler cancel@FleetEditor if ($this->missionID == 12) { $this->update('wakeUpTime', 0); } FleetLog::update($this->getObject()); }
/** * Inserts the fleet */ public function fire() { LockUtil::checkLock(WCF::getUser()->userID); LockUtil::setLock(WCF::getUser()->userID, 10); EventHandler::fireAction($this, 'shouldFire'); $this->fleetEditor = FleetEditor::create($this->startPlanetID, $this->endPlanetID, $this->ships, $this->galaxy, $this->system, $this->planet, $this->metal, $this->crystal, $this->deuterium, $this->getDuration(), $this->missionID); $planet = Planet::getInstance($this->startPlanetID); $planet->getEditor()->changeResources(-$this->metal, -$this->crystal, -($this->deuterium + $this->getConsumption())); $ships = array(); foreach ($this->ships as $specID => $shipCount) { $ships[$specID] = -$shipCount; } $planet->getEditor()->changeLevel($ships); // TODO: integrate in wcf eventlistener didFire@FleetQueue if ($this->missionID == 11) { $formation = new NavalFormation($this->formationID); $formation->getEditor()->addFleet($this->fleetEditor->fleetID); } if ($this->missionID == 12) { $standByTime = intval(@$_REQUEST['standByTime']); $wakeUpTime = $this->fleetEditor->impactTime + $standByTime; $newReturnTime = $this->fleetEditor->returnTime + $standByTime; $this->fleetEditor->changeTime(array('return' => $newReturnTime)); $wakeUpEvent = WOTEventEditor::create(1, $this->fleetEditor->fleetID, array('state' => 2), $wakeUpTime); $this->fleetEditor->update(array('wakeUpEventID' => $wakeUpEvent->eventID, 'wakeUpTime' => $wakeUpTime)); } if (WCF::getUser()->userID == 1) { FleetOvent::create($this->fleetEditor, false, true); } EventHandler::fireAction($this, 'didFire'); $this->deleteFleetQueue(); LockUtil::removeLock(WCF::getUser()->userID); }