/**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     if (!WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     $this->fleet = Fleet::getInstance($this->fleetID);
     if ($this->fleet->ownerID != WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     if (!$this->fleet->getCancelDuration()) {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     if ($this->fleet->missionID == 11) {
         $formation = $this->fleet->getNavalFormation();
     }
     $this->fleet->getEditor()->cancel();
     if ($this->fleet->missionID == 11) {
         FleetOvent::update($formation->getLeaderFleet());
     }
     $this->executed();
     header('Location: index.php?page=FleetStartShips');
     exit;
 }
 /**
  * Switches between two modes: the impact and the return 'mode'.
  * 
  * @param	array	event data
  */
 public function execute($data)
 {
     // TODO: remove this passage?
     // lock management
     echo "l";
     do {
         try {
             LockUtil::checkLock($this->ownerID);
             LockUtil::checkLock($this->ofiaraID);
             // everything checked
             break;
         } catch (SystemException $e) {
             echo 'waiting 0.5s because of a lock ...';
             usleep(500000);
         }
     } while (true);
     echo "m";
     LockUtil::setLock($this->ownerID, 10);
     if ($this->ofiaraID) {
         LockUtil::setLock($this->ofiaraID, 10);
     }
     // execute
     $this->initArrays();
     $this->eventData = $data;
     // return
     if ($data['state'] == 1) {
         if (count($this->fleet)) {
             $this->executeReturn();
             $this->sendReturnMessage();
         }
     } else {
         if ($data['state'] == 0) {
             $this->executeImpact();
             $this->sendImpactOwnerMessage();
             $this->sendImpactOfiaraMessage();
         } else {
             $this->executeUnknownEvent();
         }
     }
     // TODO: integrate this in wcf event listener?
     FleetOvent::update($this);
     // lock management
     LockUtil::removeLock($this->ownerID);
     LockUtil::removeLock($this->ofiaraID);
     return;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     if (!WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     $this->fleet = Fleet::getInstance($this->fleetID);
     // check fleet
     if ($this->fleet->impactTime <= TIME_NOW || $this->fleet->ownerID != WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     $this->navalFormation = NavalFormationEditor::create($this->fleetID, $this->fleet->ownerID);
     FleetOvent::update($this->fleet);
     $this->executed();
     header('Location: index.php?page=FleetStartShips');
     exit;
 }
 /**
  * Save Data: Saves the fleets that attacked this planet in this combat
  */
 protected function saveDataAttackFleets()
 {
     global $resource;
     $destroyedFleetIDsStr = '';
     $survivingFleetIDsArr = array();
     foreach ($this->navalFormationFleets as $fleetID => $fleetObj) {
         if (!$fleetObj->capacity) {
             $fleetObj->getEditor()->delete();
             continue;
         }
         // booty
         $capacityFactor = $fleetObj->capacity / $this->totalCapacity;
         $bootyMetal = $this->booty['metal'] * $capacityFactor;
         $bootyCrystal = $this->booty['crystal'] * $capacityFactor;
         $bootyDeuterium = $this->booty['deuterium'] * $capacityFactor;
         $fleetObj->getEditor()->changeResources($bootyMetal, $bootyCrystal, $bootyDeuterium);
         // ships
         $specArray = array();
         foreach ($this->lastRoundData['attackerData'][$fleetID] as $specID => $shipData) {
             $specArray[$specID] = $shipData['count'];
         }
         if ($fleetObj->ownerID == 1) {
             $fleetObj->addData(array('fleetObj' => print_r($this, true)));
         }
         $fleetObj->getEditor()->updateShips($specArray);
         // TODO: integrate this in wcf event listener?
         if ($fleetObj !== $this) {
             FleetOvent::update($fleetObj);
         }
     }
 }