Beispiel #1
0
 /**
  * @see Mission::check()
  */
 public static function check(FleetQueue $fleetQueue)
 {
     if ($fleetQueue->getTargetPlanet()->id_owner != $fleetQueue->getStartPlanet()->id_owner) {
         return true;
     }
     return false;
 }
Beispiel #2
0
 /**
  * @see Mission::check()
  */
 public static function check(FleetQueue $fleetQueue)
 {
     $rips = isset($fleetQueue->ships[self::RIP]);
     $foreignPlanet = $fleetQueue->getTargetPlanet()->id_owner != WCF::getUser()->userID;
     if ($rips && $foreignPlanet) {
         return true;
     }
     return false;
 }
Beispiel #3
0
 /**
  * Creates a new fleet.
  *
  * @param	int		start planet id
  * @param	int		end planet id
  * @param	array	ships
  * @param	int		galaxy
  * @param	int		system
  * @param	int		planet
  * @param	float	metal
  * @param	float	crystal
  * @param	float	deuterium
  * @param	float	duration
  * @param	int		mission id
  * @param	float	time
  * @param	int		package id
  * @return	FleetEditor
  */
 public static function create($startPlanetID, $endPlanetID, $ships, $galaxy, $system, $planet, $metal, $crystal, $deuterium, $duration, $missionID, $time = null, $packageID = PACKAGE_ID)
 {
     if ($time === null) {
         $time = round(microtime(true), 2);
     }
     $startPlanet = Planet::getInstance($startPlanetID);
     $targetPlanet = Planet::getInstance($endPlanetID);
     // init vars
     FleetQueue::readCache();
     $classPath = FleetQueue::$cache[$missionID]['classPath'];
     $ownerID = Planet::getInstance($startPlanetID)->id_owner;
     $ofiaraID = Planet::getInstance($endPlanetID)->id_owner;
     $impactTime = $time + $duration;
     $returnTime = $time + $duration * 2;
     // insert fleet
     $fleetID = self::insert($startPlanetID, $endPlanetID, $ownerID, $ofiaraID, $galaxy, $system, $planet, $metal, $crystal, $deuterium, $time, $impactTime, $returnTime, $missionID, $packageID);
     // create events
     $impactEvent = WOTEventEditor::create(1, $fleetID, array('state' => 0), $impactTime);
     $returnEvent = WOTEventEditor::create(1, $fleetID, array('state' => 1), $returnTime);
     // register events
     $fleetEditor = new FleetEditor($fleetID);
     $fleetEditor->update(array('impactEventID' => $impactEvent->eventID, 'returnEventID' => $returnEvent->eventID));
     // inserts ships
     $fleetEditor->updateShips($ships);
     // add to log
     $fleet = Fleet::getInstance($fleetID);
     FleetLog::create($fleet);
     return $fleetEditor;
 }
Beispiel #4
0
 /**
  * @see Mission::check()
  */
 public static function check(FleetQueue $fleetQueue)
 {
     $alliance = Alliance::getByUserID($fleetQueue->getTargetPlanet()->id_owner);
     $foreignPlanet = $fleetQueue->getTargetPlanet()->id_owner != WCF::getUser()->userID;
     $isBuddy = WCF::getUser()->hasBuddy($fleetQueue->getTargetPlanet()->id_owner);
     $isInAlliance = $alliance !== null && LWCore::getAlliance() !== null && $alliance->allianceID == LWCore::getAlliance()->allianceID;
     if ($fleetQueue->pageNo == 2) {
         WCF::getTPL()->assign('availableTimes', self::$availableTimes);
     }
     if ($fleetQueue->pageNo == 3) {
         $selectedTime = intval(@$_REQUEST['standByTime']);
         if (!in_array($selectedTime, self::$availableTimes)) {
             return false;
         }
     }
     if ($foreignPlanet && ($isBuddy || $isInAlliance)) {
         return true;
     }
     return false;
 }
Beispiel #5
0
 /**
  * Reads the needed class from the database and returns the fleet object
  *
  * @param	int		fleet id
  * @param	array	fleet row
  *
  * @return	Fleet	planet
  */
 public static function getInstance($fleetID, $row = null)
 {
     if ($fleetID !== null) {
         $fleetID = intval($fleetID);
     }
     FleetQueue::readCache();
     if (isset(self::$fleets[$fleetID])) {
         $fleet = self::$fleets[$fleetID];
     } else {
         if (isset(self::$fleets[$row['fleetID']])) {
             $fleetID = $row['fleetID'];
             $fleet = self::$fleets[$row['fleetID']];
         } else {
             if ($fleetID === null) {
                 $fleetID = $row['fleetID'];
                 $classPath = FleetQueue::$cache[$row['missionID']]['classPath'];
                 $className = StringUtil::getClassName($classPath);
                 if (!$row) {
                     $className = self::STANDARD_CLASS;
                     $classPath = 'lib/data/fleet/' . self::STANDARD_CLASS . '.class.php';
                 }
                 require_once LW_DIR . 'lib/data/fleet/' . $className . '.class.php';
                 $fleet = new $className($fleetID, $row);
             } else {
                 $sql = "SELECT ugml_fleet.*,\r\n\t\t\t\t\t\tGROUP_CONCAT(\r\n\t\t\t\t\t\t\tCONCAT(specID, ',', shipCount) \r\n\t\t\t\t\t\t\tSEPARATOR ';')\r\n\t\t\t\t\t\tAS fleet\r\n\t\t\t\t\tFROM ugml_fleet\r\n\t\t    \t\tLEFT JOIN ugml_fleet_spec\r\n\t\t    \t\t\tON ugml_fleet.fleetID = ugml_fleet_spec.fleetID\r\n\t\t    \t\tWHERE ugml_fleet.fleetID = " . $fleetID . "\r\n\t\t    \t\tGROUP BY ugml_fleet.fleetID";
                 $row = WCF::getDB()->getFirstRow($sql);
                 $classPath = FleetQueue::$cache[$row['missionID']]['classPath'];
                 $className = StringUtil::getClassName($classPath);
                 if (!$row) {
                     $className = self::STANDARD_CLASS;
                     $classPath = 'lib/data/fleet/' . self::STANDARD_CLASS . '.class.php';
                 }
                 require_once LW_DIR . $classPath;
                 $fleet = new $className($fleetID, $row);
             }
         }
     }
     self::$fleets[$fleetID] = $fleet;
     return $fleet;
 }
 /**
  * @see Mission::check()
  */
 public static function check(FleetQueue $fleetQueue)
 {
     $foreignPlanet = $fleetQueue->getTargetPlanet()->id_owner != WCF::getUser()->userID;
     $formations = NavalFormation::getByTargetPlanetID($fleetQueue->getTargetPlanet()->planetID, WCF::getUser()->userID);
     if ($foreignPlanet && count($formations)) {
         return true;
     }
     return false;
 }
Beispiel #7
0
//fleetback.php
define('INSIDE', true);
$ugamela_root_path = '../';
include $ugamela_root_path . 'extension.inc';
include $ugamela_root_path . 'common.' . $phpEx;
if (!check_user()) {
    header("Location: login.php");
    die;
}
$start = intval($_GET['start']);
$sql = "SELECT * \r\n\t\tFROM `ugml_fleet` \r\n\t\tLEFT JOIN ugml_event ON ugml_fleet.returnEventID = ugml_event.eventID\r\n\t\tWHERE eventID IS NULL";
$result = WCF::getDB()->sendQuery($sql);
require_once LW_DIR . 'lib/data/fleet/FleetEditor.class.php';
require_once LW_DIR . 'lib/data/fleet/queue/FleetQueue.class.php';
require_once LW_DIR . 'lib/system/event/WOTEventEditor.class.php';
FleetQueue::readCache();
$i = 0;
while ($row = WCF::getDB()->fetchArray($result)) {
    $i++;
    $editor = new FleetEditor($row['fleetID']);
    $impactEvent = WOTEventEditor::create(1, $row['fleetID'], array('state' => 0), time() + 1);
    $returnEvent = WOTEventEditor::create(1, $row['fleetID'], array('state' => 1), time() + 121);
    $editor->update(array('impactEventID' => $returnEvent->eventID->eventID, 'returnEventID' => $returnEvent->eventID));
    echo 'done' . $row['fleetID'] . ';';
    /*
    	
    	$startPlanetID = $row['startPlanetID'];
    	
    	$targetPlanetID = $row['endPlanetID'];
    	
    	$ships = array();
 /**
  * @see FleetQueue::fire()
  */
 public function fire()
 {
     parent::fire();
     $this->fleetEditor->update('primaryDestination', $this->primaryDestination);
 }
Beispiel #9
0
 /**
  * Reads the missions cache.
  */
 public static function readCache()
 {
     if (!count(self::$cache)) {
         WCF::getCache()->addResource('missions-' . PACKAGE_ID, WCF_DIR . 'cache/cache.missions-' . PACKAGE_ID . '.php', LW_DIR . 'lib/system/cache/CacheBuilderMissions.class.php');
         self::$cache = WCF::getCache()->get('missions-' . PACKAGE_ID);
     }
 }