示例#1
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;
 }
示例#2
0
文件: fixer.php 项目: sonicmaster/RPG
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();
    	$parts = explode(';', $row['fleet_array']);
    	foreach($parts as $part) {
    		if(strlen($part) < 2) {
    			continue;
示例#3
0
require_once '../game/lib/data/fleet/Fleet.class.php';
require_once '../game/lib/util/LWUtil.class.php';
require_once '../game/lib/system/spec/Spec.class.php';
$fleetStr = "10753267";
$fleetStrs = explode(",", $fleetStr);
$fleetData = array();
/*foreach($fleetStrs as $fleetID) {
	$sql 
	//$fleets += Fleet::getInstance($fleetID);
}*/
$sql = "SELECT *\n\t\tFROM ugml_archive_fleet\n\t\tWHERE fleetID IN(" . $fleetStr . ")\n\t\tORDER BY missionID ASC";
$result = WCF::getDB()->sendQuery($sql);
$formationID = 7028;
while ($row = WCF::getDB()->fetchArray($result)) {
    $data = unserialize(LWUtil::unserialize($row['data']));
    $fleet = FleetEditor::create($data[0]['data']['startPlanetID'], $data[0]['data']['targetPlanetID'], $data[0]['fleet'], $data[0]['data']['galaxy'], $data[0]['data']['system'], $data[0]['data']['planet'], $data[0]['data']['metal'], $data[0]['data']['crystal'], $data[0]['data']['deuterium'], $data[0]['data']['missionID'] == 12 ? 600 : 1200, $data[0]['data']['missionID']);
    /*if($data[0]['data']['missionID'] == 12) {		
    		$fleet->changeTime(array('return' => 2400 + time()));
    		
    		$wakeUpEvent = WOTEventEditor::create(1, $fleet->fleetID, array('state' => 2), time() + 1800);
    	
    		$fleet->update(array('wakeUpEventID' => $wakeUpEvent->eventID, 'wakeUpTime' => time() + 1800));
    	}
    	else if($data[0]['data']['missionID'] == 11) {*/
    $formation = new NavalFormation($formationID);
    $formation->getEditor()->addFleet($fleet->fleetID);
    //}
    /*else {
    		$formation = NavalFormationEditor::create($fleet->fleetID, $fleet->ownerID);
    		$formationID = $formation->formationID;
    	}*/
示例#4
0
    $fleetID = FleetEditor::insert($startPlanetID, $targetPlanetID, $ownerID, $ofiaraID, $galaxy, $system, $planet, $metal, $crystal, $deuterium, $startTime, $impactTime, $returnTime, $missionID);
    if ($row['fleet_mess'] == 0) {
        $impactEvent = WOTEventEditor::create(1, $fleetID, array('state' => 0), $impactTime);
        $impactEventID = $impactEvent->eventID;
    } else {
        $impactEventID = 0;
    }
    $returnEvent = WOTEventEditor::create(1, $fleetID, array('state' => 1), $returnTime);
    $returnEventID = $returnEvent->eventID;
    if ($wakeUpTime) {
        $wakeUpEvent = WOTEventEditor::create(1, $fleetID, array('state' => 2), $wakeUpTime);
        $wakeUpEventID = $wakeUpEvent->eventID;
    } else {
        $wakeUpEventID = 0;
    }
    $fleetEditor = new FleetEditor($fleetID);
    $fleetEditor->update(array('formationID' => $formationID, 'impactEventID' => $impactEventID, 'returnEventID' => $returnEventID, 'wakeUpEventID' => $wakeUpEventID, 'wakeUpTime' => $wakeUpTime));
    $fleetEditor->updateShips($ships);
}
sleep(5);
?>
done;
<script>
	window.location.href = 'update.php?start=<?php 
/*
  This file is part of WOT Game.

    WOT Game is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
示例#5
0
 /**
  * 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);
 }