Example #1
0
 /**
  * Creates the ovents for a fleet.
  * 
  * @param	Fleet	fleet
  * @param	bool	delete old ovents (= update)
  * @param	bool	wrap in transaction
  */
 public static function create($fleet, $deleteOld = true, $transact = false)
 {
     if ($transact) {
         WCF::getDB()->sendQuery("SET AUTOCOMMIT = 0");
         WCF::getDB()->sendQuery("START TRANSACTION");
     }
     if ($deleteOld) {
         $sql = "DELETE FROM ugml_ovent\r\n\t\t\t\t\tWHERE oventTypeID = " . self::OVENT_TYPE_ID . "\r\n\t\t\t\t\t\tAND relationalID = " . $fleet->fleetID;
     }
     $data = array('ownerID' => $fleet->ownerID, 'ofiaraID' => $fleet->ofiaraID, 'startPlanetID' => $fleet->startPlanetID, 'targetPlanetID' => $fleet->targetPlanetID, 'resources' => array('metal' => $fleet->metal, 'crystal' => $fleet->crystal, 'deuterium' => $fleet->deuterium), 'startCoords' => array($fleet->getStartPlanet()->galaxy, $fleet->getStartPlanet()->system, $fleet->getStartPlanet()->planet, $fleet->getStartPlanet()->planetKind), 'targetCoords' => array($fleet->getTargetPlanet()->galaxy, $fleet->getTargetPlanet()->system, $fleet->getTargetPlanet()->planet, $fleet->getTargetPlanet()->planetKind), 'spec' => $fleet->fleet, 'cssClass' => $fleet->getClassName(true), 'missionID' => $fleet->missionID, 'startPlanetName' => $fleet->getStartPlanet()->name, 'targetPlanetName' => $fleet->getTargetPlanet()->name, 'fleetID' => $fleet->fleetID);
     $ownerFields = array('userID' => $fleet->ownerID, 'planetID' => $fleet->startPlanetID);
     $ofiaraFields = array('userID' => $fleet->ofiaraID, 'planetID' => $fleet->targetPlanetID);
     $data['passage'] = 'flight';
     OventEditor::create(self::OVENT_TYPE_ID, $fleet->impactTime, $fleet->impactEventID, $fleet->fleetID, $ownerFields, 0, $data);
     $data['passage'] = 'return';
     OventEditor::create(self::OVENT_TYPE_ID, $fleet->returnTime, $fleet->returnEventID, $fleet->fleetID, $ownerFields, 0, $data);
     if ($ownerID != $ofiaraID && $ofiaraID > 0) {
         $data['cssClass'] = $fleet->getClassName(false);
         $data['passage'] = 'flight';
         OventEditor::create(self::OVENT_TYPE_ID, $fleet->impactTime, $fleet->impactEventID, $fleet->fleetID, $ofiaraFields, 0, $data);
     }
     // TODO: integrate this in wcf eventhandler
     if ($fleet->missionID == 11) {
         // what NAO ?!
     } else {
         if ($fleet->missionID == 12) {
             $data['cssClass'] = $fleet->getClassName(true);
             $data['passage'] = 'standBy';
             OventEditor::create(self::OVENT_TYPE_ID, $fleet->wakeUpTime, $fleet->wakeUpEventID, $fleet->fleetID, $ownerFields, 0, $data);
             $data['cssClass'] = $fleet->getClassName(false);
             OventEditor::create(self::OVENT_TYPE_ID, $fleet->wakeUpTime, $fleet->wakeUpEventID, $fleet->fleetID, $ofiaraFields, 0, $data);
         }
     }
     if ($transact) {
         WCF::getDB()->sendQuery("COMMIT");
         WCF::getDB()->sendQuery("SET AUTOCOMMIT = 1");
     }
 }
Example #2
0
 /**
  * Updates the building ovent for a planet.
  *
  * @param	int		planet id
  */
 public static function check($planetID)
 {
     $ovents = Ovent::getByConditions(array('planetID' => $planetID, 'oventTypeID' => self::OVENT_TYPE_ID));
     $planet = Planet::getInstance($planetID);
     // event needed
     if ($planet->b_building > time()) {
         if (isset($ovents[0])) {
             if ($ovents[0]->time == $planet->b_building) {
                 // no changes needed
                 return;
             }
             // delete old ovent
             $ovents[0]->getEditor()->delete();
         }
         // create new
         $data = self::getData($planet);
         $fields = array('userID' => $planet->id_owner, 'planetID' => $planetID);
         OventEditor::create(self::OVENT_TYPE_ID, $planet->b_building, null, $planetID, $fields, 0, $data);
     } else {
         foreach ($ovents as $ovent) {
             $ovent->getEditor()->delete();
         }
     }
 }
Example #3
0
 /**
  * Creates the ovents for a fleet.
  * 
  * @param	Fleet	fleet
  * @param	bool	delete old ovents (= update)
  * @param	bool	wrap in transaction
  * @todo move this to FleetOventEditor
  */
 public static function create($fleet, $deleteOld = true, $transact = false, $forceNfsUpdate = false)
 {
     if ($transact) {
         WCF::getDB()->sendQuery("SET AUTOCOMMIT = 0");
         WCF::getDB()->sendQuery("START TRANSACTION");
     }
     if ($deleteOld) {
         $sql = "DELETE FROM ugml_ovent\n\t\t\t\t\tWHERE oventTypeID = " . self::OVENT_TYPE_ID . "\n\t\t\t\t\t\tAND relationalID = " . $fleet->fleetID;
     }
     $data = self::getData($fleet);
     $ownerFields = array('userID' => $fleet->ownerID, 'planetID' => $fleet->startPlanetID);
     $ofiaraFields = array('userID' => $fleet->ofiaraID, 'planetID' => $fleet->targetPlanetID);
     $data['passage'] = 'flight';
     $impactOwnerOvent = OventEditor::create(self::OVENT_TYPE_ID, $fleet->impactTime, $fleet->impactEventID, $fleet->fleetID, $ownerFields, 0, array($data));
     $data['passage'] = 'return';
     $returnOwnerOvent = OventEditor::create(self::OVENT_TYPE_ID, $fleet->returnTime, $fleet->returnEventID, $fleet->fleetID, $ownerFields, 0, array($data));
     if ($fleet->ownerID != $fleet->ofiaraID && $fleet->ofiaraID > 0) {
         $data['passage'] = 'flight';
         $impactOfiaraOvent = OventEditor::create(self::OVENT_TYPE_ID, $fleet->impactTime, $fleet->impactEventID, $fleet->fleetID, $ofiaraFields, 0, array($data));
         if (stripos(get_class($fleet), "attack") !== false || stripos(get_class($fleet), "destroy") !== false) {
             $impactOfiaraOvent->setHighlighted(true);
         }
     }
     // TODO: integrate this in wcf eventhandler
     if ($fleet->missionID == 11) {
         $formation = $fleet->getNavalFormation();
         $fleets = $formation->fleets;
         $leaderFleet = $formation->getLeaderFleet();
         $leaderFleetID = $leaderFleet->fleetID;
         if (count($fleets) > 1 || $forceNfsUpdate) {
             $impactOwnerOvent->getEditor()->delete();
             $impactOfiaraOvent->getEditor()->delete();
             $ovents = Ovent::getByConditions(array('relationalID' => $leaderFleetID, 'oventTypeID' => self::OVENT_TYPE_ID));
             foreach ($ovents as $ovent) {
                 $oventData = $ovent->getPoolData();
                 if ($oventData[0]['passage'] == 'flight') {
                     $ovent->getEditor()->delete();
                 }
             }
             $data['passage'] = 'flight';
             $odata = array($data);
             foreach ($fleets as $fleetID => $fleetObj) {
                 if ($fleetID != $fleet->fleetID) {
                     $odata[] = self::getData($fleetObj, array('passage' => 'flight'));
                 }
             }
             $impactOwnerOvent = OventEditor::create(self::OVENT_TYPE_ID, $fleet->impactTime, $leaderFleet->impactEventID, $leaderFleetID, $ownerFields, 0, $odata);
             foreach ($formation->users as $userID => $user) {
                 if ($userID != $fleet->ownerID) {
                     $ownerFields['userID'] = $userID;
                     OventEditor::create(self::OVENT_TYPE_ID, $fleet->impactTime, $leaderFleet->impactEventID, $leaderFleetID, $ownerFields, 0, $odata);
                 }
             }
             $ownerFields['userID'] = $fleet->ownerID;
             $impactOfiaraOvent = OventEditor::create(self::OVENT_TYPE_ID, $fleet->impactTime, $leaderFleet->impactEventID, $leaderFleetID, $ofiaraFields, 0, $odata);
             $impactOfiaraOvent->setHighlighted(true);
         }
     } else {
         if ($fleet->missionID == 12) {
             $data['passage'] = 'restart';
             $standByOwnerOvent = OventEditor::create(self::OVENT_TYPE_ID, $fleet->wakeUpTime, $fleet->wakeUpEventID, $fleet->fleetID, $ownerFields, 0, array($data));
             $standByOfiaraOvent = OventEditor::create(self::OVENT_TYPE_ID, $fleet->wakeUpTime, $fleet->wakeUpEventID, $fleet->fleetID, $ofiaraFields, 0, array($data));
         }
     }
     if ($transact) {
         WCF::getDB()->sendQuery("COMMIT");
         WCF::getDB()->sendQuery("SET AUTOCOMMIT = 1");
     }
 }