Exemplo n.º 1
0
 /**
  * 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());
 }