示例#1
0
 /**
  * The required method to handle the Alert.
  *
  * @return mixed
  */
 protected function getData() : Collection
 {
     // Get the corporations we know about.
     $corporation_ids = Starbase::select('corporationID')->groupBy('corporationID')->pluck('corporationID');
     // Prepare the return collection.
     $siphon = collect();
     // Go over each corporation ...
     $corporation_ids->each(function ($corporation_id) use(&$siphon) {
         // .. and check the details of each starbase
         $this->getCorporationStarbases($corporation_id)->each(function ($starbase) use($corporation_id, &$siphon) {
             // Get the details (with module details) of a specific starbase
             $details = $this->getCorporationStarbases($corporation_id, $starbase->itemID);
             // Loop over each module at the starbase and
             // check if it looks like a siphon is present on a silo.
             $details->modules->each(function ($module) use($corporation_id, $starbase, &$siphon) {
                 if ($module['detail']->typeID == 14343 && $module['used_volume'] % 100 > 0) {
                     // Push information about this module as one
                     // that is possibly being siphoned.
                     $siphon->push(['corporation_id' => $corporation_id, 'type' => $starbase->starbaseTypeName, 'name' => $starbase->starbaseName, 'location' => $starbase->moonName, 'silo_used_volume' => $module['used_volume']]);
                 }
             });
         });
     });
     return $siphon;
 }
示例#2
0
 /**
  * Return a list of starbases for a Corporation. If
  * a starbaseID is provided, then only data for that
  * starbase is returned.
  *
  * @param int $corporation_id
  * @param int $starbase_id
  *
  * @return
  */
 public function getCorporationStarbases(int $corporation_id, int $starbase_id = null)
 {
     $starbase = Starbase::select('corporation_starbases.itemID', 'corporation_starbases.moonID', 'corporation_starbases.state', 'corporation_starbases.stateTimeStamp', 'corporation_starbases.onlineTimeStamp', 'corporation_starbases.onlineTimeStamp', 'corporation_starbase_details.useStandingsFrom', 'corporation_starbase_details.onAggression', 'corporation_starbase_details.onCorporationWar', 'corporation_starbase_details.allowCorporationMembers', 'corporation_starbase_details.allowAllianceMembers', 'corporation_starbase_details.fuelBlocks', 'corporation_starbase_details.strontium', 'corporation_starbase_details.starbaseCharter', 'invTypes.typeID as starbaseTypeID', 'invTypes.typeName as starbaseTypeName', 'mapDenormalize.itemName as mapName', 'mapDenormalize.security as mapSecurity', 'invNames.itemName as moonName', 'map_sovereignties.solarSystemName', 'corporation_starbase_details.updated_at')->selectSub(function ($query) {
         return $query->from('invControlTowerResources')->select('quantity')->whereBetween('resourceTypeID', [4000, 5000])->where('purpose', 1)->where('controlTowerTypeID', $query->raw('corporation_starbases.typeID'));
     }, 'baseFuelUsage')->selectSub(function ($query) {
         return $query->from('invControlTowerResources')->select('quantity')->where('resourceTypeID', '=', 16275)->where('purpose', 4)->where('controlTowerTypeID', $query->raw('corporation_starbases.typeID'));
     }, 'baseStrontUsage')->selectSub(function ($query) {
         return $query->from('invTypes')->select('capacity')->where('groupID', 365)->where('typeID', $query->raw('corporation_starbases.typeID'));
     }, 'fuelBaySize')->selectSub(function ($query) {
         return $query->from('dgmTypeAttributes')->select('valueFloat')->where('dgmTypeAttributes.attributeID', 1233)->where('typeID', $query->raw('corporation_starbases.typeID'));
     }, 'strontBaySize')->selectSub(function ($query) {
         return $query->from('corporation_locations')->select('itemName')->where('itemID', $query->raw('corporation_starbases.itemID'));
     }, 'starbaseName')->selectSub(function ($query) use($corporation_id) {
         return $query->from('map_sovereignties')->selectRaw('IF(solarSystemID, TRUE, FALSE) inSovSystem')->where('factionID', 0)->whereIn('allianceID', function ($subquery) use($corporation_id) {
             $subquery->from('corporation_sheets')->select('allianceID')->where('corporationID', $corporation_id);
         })->where('solarSystemID', $query->raw('corporation_starbases.locationID'));
     }, 'inSovSystem')->selectSub(function ($query) {
         return $query->from('dgmTypeAttributes')->select('valueFloat')->where('attributeID', 757)->where('typeID', $query->raw('corporation_starbases.typeID'));
     }, 'siloCapacityBonus')->join('corporation_starbase_details', 'corporation_starbases.itemID', '=', 'corporation_starbase_details.itemID')->join('mapDenormalize', 'corporation_starbases.locationID', '=', 'mapDenormalize.itemID')->join('invNames', 'corporation_starbases.moonID', '=', 'invNames.itemID')->join('invTypes', 'corporation_starbases.typeID', '=', 'invTypes.typeID')->leftJoin('map_sovereignties', 'corporation_starbases.locationID', '=', 'map_sovereignties.solarSystemID')->where('corporation_starbases.corporationID', $corporation_id)->orderBy('invNames.itemName', 'asc');
     // If we did get a specific starbase_id to query then
     // just return what we have now for all of the starbases.
     if (is_null($starbase_id)) {
         return $starbase->get();
     }
     // ... otherwise, filter down to the specific requested starbase
     // and grab some extra information about the silos etc at this tower.
     $starbase = $starbase->where('corporation_starbases.itemID', $starbase_id)->first();
     // When calculating *actual* silo capacity, we need
     // to keep in mind that certain towers have bonusses
     // to silo cargo capacity, like amarr & gallente
     // towers do now. To calculate this, we will get the
     // siloCapacityBonus value from the starbase and add the
     // % capacity to actual modules that benefit from
     // the bonusses.
     $cargo_types_with_bonus = [14343, 17982];
     // Silo, Coupling Array
     $assetlist_locations = $this->getCorporationAssetByLocation($corporation_id);
     $module_contents = $this->getCorporationAssetContents($corporation_id);
     // Check if we know of *any* assets at the moon where this tower is.
     if ($assetlist_locations->has($starbase->moonID)) {
         // Set the 'modules' key for the starbase
         $starbase->modules = $assetlist_locations->get($starbase->moonID)->map(function ($asset) use($starbase, $cargo_types_with_bonus, $module_contents) {
             // Return a collection with module related info.
             return ['detail' => $asset, 'used_volume' => $module_contents->where('parentAssetItemID', $asset->itemID)->sum(function ($_) {
                 return $_->quantity * $_->volume;
             }), 'available_volume' => in_array($asset->typeID, $cargo_types_with_bonus) ? $asset->capacity * (1 + $starbase->siloCapacityBonus / 100) : $asset->capacity, 'total_items' => $module_contents->where('parentAssetItemID', $asset->itemID)->sum('quantity')];
         });
     }
     return $starbase;
 }
 /**
  * The required method to handle the Alert.
  *
  * @return mixed
  */
 protected function getData() : Collection
 {
     // Get the corporations we know about.
     $corporation_ids = Starbase::select('corporationID')->groupBy('corporationID')->pluck('corporationID');
     // Prepare the return collection.
     $starbases = collect();
     // Go over each corporation ...
     $corporation_ids->each(function ($corporation_id) use(&$starbases) {
         // .. and check the details of each starbase
         $this->getCorporationStarbases($corporation_id)->each(function ($starbase) use($corporation_id, &$starbases) {
             $starbases->push(['corporation_id' => $corporation_id, 'type' => $starbase->starbaseTypeName, 'name' => $starbase->starbaseName, 'location' => $starbase->moonName, 'state' => $starbase->state, 'state_name' => $this->getEveStarbaseTowerStates()[$starbase->state], 'state_timestamp' => $starbase->stateTimeStamp]);
         });
     });
     return $starbases;
 }
示例#4
0
 /**
  * Run the Update
  *
  * @return mixed|void
  */
 public function call()
 {
     $pheal = $this->setScope('corp')->setCorporationID()->getPheal();
     $result = $pheal->StarbaseList();
     foreach ($result->starbases as $starbase) {
         $starbase_info = Starbase::firstOrNew(['corporationID' => $this->corporationID, 'itemID' => $starbase->itemID]);
         $starbase_info->fill(['typeID' => $starbase->typeID, 'locationID' => $starbase->locationID, 'moonID' => $starbase->moonID, 'state' => $starbase->state, 'stateTimestamp' => $starbase->stateTimestamp, 'onlineTimestamp' => $starbase->onlineTimestamp, 'standingOwnerID' => $starbase->standingOwnerID]);
         $starbase_info->save();
     }
     // Cleanup old Starbases
     Starbase::where('corporationID', $this->corporationID)->whereNotIn('itemID', array_map(function ($starbase) {
         return $starbase->itemID;
     }, (array) $result->starbases))->delete();
     // Cleanup old Starbase details.
     StarbaseDetailModel::where('corporationID', $this->corporationID)->whereNotIn('itemID', array_map(function ($starbase) {
         return $starbase->itemID;
     }, (array) $result->starbases))->delete();
     return;
 }
示例#5
0
 /**
  * The required method to handle the Alert.
  *
  * @return mixed
  */
 protected function getData() : Collection
 {
     // Get the corporations we know about.
     $corporation_ids = Starbase::select('corporationID')->groupBy('corporationID')->pluck('corporationID');
     // Prepare the return collection.
     $low_feul = collect();
     // Go over each corporation ...
     $corporation_ids->each(function ($corporation_id) use(&$low_feul) {
         // .. and check the details of each starbase
         $this->getCorporationStarbases($corporation_id)->each(function ($starbase) use($corporation_id, &$low_feul) {
             $info = ['corporation_id' => $corporation_id, 'type' => $starbase->starbaseTypeName, 'name' => $starbase->starbaseName, 'location' => $starbase->moonName, 'hours_left' => carbon('now')->diffInHours(carbon('now')->addHours($starbase->fuelBlocks / ceil($starbase->baseFuelUsage * ($starbase->inSovSystem ? 0.75 : 1)))), 'fuel_blocks' => $starbase->fuelBlocks, 'estimated_offline' => carbon('now')->addHours($starbase->fuelBlocks / ceil($starbase->baseFuelUsage * ($starbase->inSovSystem ? 0.75 : 1)))->diffForHumans()];
             // If the fuel is low, add it to the collection!
             if ($info['hours_left'] < 24) {
                 $low_feul->push($info);
             }
         });
     });
     return $low_feul;
 }
示例#6
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $possible_corp_starbases = Starbase::where('corporationID', $this->route('corporation_id'))->lists('itemID')->implode(',');
     return ['starbase_id' => 'required|numeric|in:' . $possible_corp_starbases];
 }
 /**
  * Return a list of starbases for a Corporation. If
  * a starbaseID is provided, then only data for that
  * starbase is returned.
  *
  * @param      $corporation_id
  * @param null $starbase_id
  *
  * @return mixed
  */
 public function getCorporationStarbases($corporation_id, $starbase_id = null)
 {
     $starbase = Starbase::select('corporation_starbases.itemID', 'corporation_starbases.moonID', 'corporation_starbases.state', 'corporation_starbases.stateTimeStamp', 'corporation_starbases.onlineTimeStamp', 'corporation_starbases.onlineTimeStamp', 'corporation_starbase_details.useStandingsFrom', 'corporation_starbase_details.onAggression', 'corporation_starbase_details.onCorporationWar', 'corporation_starbase_details.allowCorporationMembers', 'corporation_starbase_details.allowAllianceMembers', 'corporation_starbase_details.fuelBlocks', 'corporation_starbase_details.strontium', 'corporation_starbase_details.starbaseCharter', 'invTypes.typeID as starbaseTypeID', 'invTypes.typeName as starbaseTypeName', 'mapDenormalize.itemName as mapName', 'mapDenormalize.security as mapSecurity', 'invNames.itemName as moonName', 'map_sovereignties.solarSystemName', 'corporation_starbase_details.updated_at')->selectSub(function ($query) {
         return $query->from('invControlTowerResources')->select('quantity')->whereBetween('resourceTypeID', [4000, 5000])->where('purpose', 1)->where('controlTowerTypeID', $query->raw('corporation_starbases.typeID'));
     }, 'baseFuelUsage')->selectSub(function ($query) {
         return $query->from('invControlTowerResources')->select('quantity')->where('resourceTypeID', '=', 16275)->where('purpose', 4)->where('controlTowerTypeID', $query->raw('corporation_starbases.typeID'));
     }, 'baseStrontUsage')->selectSub(function ($query) {
         return $query->from('invTypes')->select('capacity')->where('groupID', 365)->where('typeID', $query->raw('corporation_starbases.typeID'));
     }, 'fuelBaySize')->selectSub(function ($query) {
         return $query->from('dgmTypeAttributes')->select('valueFloat')->where('dgmTypeAttributes.attributeID', 1233)->where('typeID', $query->raw('corporation_starbases.typeID'));
     }, 'strontBaySize')->selectSub(function ($query) {
         return $query->from('corporation_locations')->select('itemName')->where('itemID', $query->raw('corporation_starbases.itemID'));
     }, 'starbaseName')->selectSub(function ($query) use($corporation_id) {
         return $query->from('map_sovereignties')->selectRaw('IF(solarSystemID, TRUE, FALSE) inSovSystem')->where('factionID', 0)->whereIn('allianceID', function ($subquery) use($corporation_id) {
             $subquery->from('corporation_sheets')->select('allianceID')->where('corporationID', $corporation_id);
         })->where('solarSystemID', $query->raw('corporation_starbases.locationID'));
     }, 'inSovSystem')->selectSub(function ($query) {
         return $query->from('dgmTypeAttributes')->select('valueFloat')->where('attributeID', 757)->where('typeID', $query->raw('corporation_starbases.typeID'));
     }, 'siloCapacityBonus')->join('corporation_starbase_details', 'corporation_starbases.itemID', '=', 'corporation_starbase_details.itemID')->join('mapDenormalize', 'corporation_starbases.locationID', '=', 'mapDenormalize.itemID')->join('invNames', 'corporation_starbases.moonID', '=', 'invNames.itemID')->join('invTypes', 'corporation_starbases.typeID', '=', 'invTypes.typeID')->leftJoin('map_sovereignties', 'corporation_starbases.locationID', '=', 'map_sovereignties.solarSystemID')->where('corporation_starbases.corporationID', $corporation_id)->orderBy('invNames.itemName', 'asc');
     if (is_null($starbase_id)) {
         return $starbase->get();
     }
     return $starbase->where('corporation_starbases.itemID', $starbase_id)->first();
 }