/**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['fleetID'])) {
         $this->fleetID = LWUtil::checkInt($_REQUEST['fleetID']);
     }
 }
Beispiel #2
0
 /**
  * Returns the spec object of the used drive.
  * 
  * @param	LWUser	user
  * @return	Spec	drive
  */
 public function getDrive()
 {
     $drives = array();
     if ($this->drive == null) {
         return null;
     }
     foreach ($this->drive as $driveSpecID => $driveData) {
         $driveObj = self::getSpecObj($driveSpecID);
         $driveColName = $driveObj->colName;
         $driveLevel = self::$user->{$driveColName};
         // check
         if (LWUtil::checkInt($driveLevel, $driveData['min'], $driveData['max']) != $driveLevel) {
             continue;
         }
         // we must use intval here, because array_flip can only flip strings and integers (no floats)
         $drives[$driveSpecID] = intval($driveData['speed'] + $driveData['speed'] * self::$user->{$driveColName} * $driveData['factor']);
     }
     if (!count($drives)) {
         return null;
     }
     asort($drives, SORT_NUMERIC);
     $drives = array_flip($drives);
     $driveSpecID = array_pop($drives);
     return self::getSpecObj($driveSpecID);
 }
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['type'])) {
         $this->type = StringUtil::trim($_REQUEST['type']);
     }
     if (isset($_REQUEST['name'])) {
         $this->name = StringUtil::trim($_REQUEST['name']);
     }
     if (isset($_REQUEST['startInput']) && !empty($_REQUEST['startInput'])) {
         $this->start = LWUtil::checkInt($_REQUEST['startInput'], 1);
         if ($this->start >= 1 && $this->start <= 99) {
             // e.g. 5 => 501; 14 => 1401
             $this->start *= 100;
             $this->start++;
         }
     } else {
         if (isset($_REQUEST['start'])) {
             $this->start = LWUtil::checkInt($_REQUEST['start'], 0);
         } else {
             if (isset($_REQUEST['relationalID'])) {
                 $this->relationalID = LWUtil::checkInt($_REQUEST['relationalID']);
             }
         }
     }
     if (isset($_REQUEST['rowCount'])) {
         $this->rowCount = LWUtil::checkInt($_REQUEST['rowCount'], 10, 500);
     }
 }
 /**
  * Decides which drives is used.
  * 
  * @param	int		spec id
  * @param	LWUser	drive
  */
 public static function getDriveSpecID($specID, $user = null)
 {
     if ($user === null) {
         $user = WCF::getUser();
     }
     $specs = WCF::getCache()->get('spec-' . PACKAGE_ID, 'bySpecID');
     $spec = $specs[$specID];
     $drives = array();
     foreach ($spec['drive'] as $driveSpecID => $drive) {
         $driveColName = BasicSpecUtil::getColName($driveSpecID);
         $driveLevel = $user->{$driveColName};
         // check
         if (LWUtil::checkInt($driveLevel, $drive['min'], $drive['max']) != $driveLevel) {
             continue;
         }
         // we must use intval here, because array_flip can only flip strings and integers
         $drives[$driveSpecID] = intval($drive['speed'] + $drive['speed'] * $user->{$driveColName} * $drive['factor']);
     }
     if (!count($drives)) {
         return null;
     }
     asort($drives, SORT_NUMERIC);
     //var_dump($drives);
     $drives = array_flip($drives);
     return array_pop($drives);
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['primaryDestination'])) {
         $this->primaryDestination = LWUtil::checkInt($_REQUEST['primaryDestination']);
     }
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['oventID'])) {
         $this->oventID = LWUtil::checkInt($_REQUEST['oventID']);
     }
     if (isset($_REQUEST['highlighted'])) {
         $this->highlighted = LWUtil::checkInt($_REQUEST['highlighted'], 0, 1);
     }
 }
 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     $specs = Spec::getBySpecType(3);
     foreach ($specs as $specID => $specObj) {
         $shipCount = LWUtil::checkInt(@$_REQUEST['ship' . $specID], 0, $specObj->level);
         if ($shipCount) {
             $specObj->level = $shipCount;
             $this->specs[$specID] = clone $specObj;
             $this->ships[$specID] = $shipCount;
         }
     }
 }
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['fleetID'])) {
         $this->fleetID = LWUtil::checkInt($_REQUEST['fleetID']);
     }
     if (isset($_GET['doSearch'])) {
         try {
             $this->validate();
             // no errors
             $this->save();
         } catch (UserInputException $e) {
             $this->errorField = $e->getField();
             $this->errorType = $e->getType();
         }
     }
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['mission'])) {
         $this->missionID = LWUtil::checkInt($_REQUEST['mission']);
     }
     if (isset($_REQUEST['metal'])) {
         $this->metal = LWUtil::checkInt($_REQUEST['metal'], 0, LWCore::getPlanet()->metal);
     }
     if (isset($_REQUEST['crystal'])) {
         $this->crystal = LWUtil::checkInt($_REQUEST['crystal'], 0, LWCore::getPlanet()->crystal);
     }
     if (isset($_REQUEST['deuterium'])) {
         $this->deuterium = LWUtil::checkInt($_REQUEST['deuterium'], 0, LWCore::getPlanet()->deuterium);
     }
     //TODO: integrate this in wcf eventlistener readParameters@FleetStartFireAction
     if (isset($_REQUEST['formation'])) {
         $this->formationID = LWUtil::checkInt($_REQUEST['formation']);
     }
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['allianceID'])) {
         $this->allianceID = LWUtil::checkInt($_REQUEST['allianceID']);
     } else {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     if (isset($_REQUEST['userID'])) {
         $this->userID = LWUtil::checkInt($_REQUEST['userID']);
     } else {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     if (isset($_REQUEST['rankID'])) {
         $this->rankID = LWUtil::checkInt($_REQUEST['rankID'], -1);
     } else {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
 }
 /**
  * Saves a given target to the fleet queue.
  */
 protected function readTarget()
 {
     if (isset($_REQUEST['targetPlanetID'])) {
         $this->targetPlanetID = LWUtil::checkInt($_REQUEST['targetPlanetID']);
     } else {
         if (isset($_REQUEST['galaxy'])) {
             $this->galaxy = LWUtil::checkInt($_REQUEST['galaxy'], 1, 9);
         }
         if (isset($_REQUEST['system'])) {
             $this->system = LWUtil::checkInt($_REQUEST['system'], 1, 499);
         }
         if (isset($_REQUEST['planet'])) {
             $this->planet = LWUtil::checkInt($_REQUEST['planet'], 1, 15);
         }
         if (isset($_REQUEST['planetType'])) {
             $this->planetType = LWUtil::checkInt($_REQUEST['planetType'], 1, 3);
         }
         if (isset($_REQUEST['missionID'])) {
             $this->fleetQueue->missionID = LWUtil::checkInt($_REQUEST['missionID']);
         }
     }
     // planet
     $this->fleetQueue->startPlanetID = LWCore::getPlanet()->planetID;
     $this->planetObj = Planet::getInstance($this->targetPlanetID);
     if ($this->planetObj->planetID) {
         $this->fleetQueue->storePlanet($this->planetObj);
         return;
     }
     $this->systemObj = new System($this->galaxy, $this->system);
     $this->planetObj = $this->systemObj->getPlanet($this->planet, $this->planetType);
     if ($this->planetObj !== null) {
         $this->fleetQueue->storePlanet($this->planetObj);
     }
 }
 /**
  * Reads the parameters of the specs.
  */
 public function readParametersSpec()
 {
     $specs = Spec::getBySpecType($this->lookForSpecType, false);
     foreach ($specs as $specID => $specObj) {
         if (isset($_REQUEST['spec' . $specID]) && intval($_REQUEST['spec' . $specID])) {
             $this->spec[$specID] = LWUtil::checkInt($_REQUEST['spec' . $specID], 0, $specObj->level);
         }
     }
 }