Exemplo n.º 1
0
 /**
  * Live Scoreboard
  *
  * @return array
  * @internal param int $id Server ID
  */
 public function population()
 {
     // Get active servers only
     $servers = Server::active()->get();
     // Sum the used slots
     $usedSlots = $servers->sum('usedSlots');
     // Sum the max slots
     $totalSlots = $servers->sum('maxSlots');
     // Init array
     $newCollection = [];
     foreach ($servers as $server) {
         // Convert the game name to lowercase
         $gameKey = strtolower($server->game->Name);
         // Add the server to the collection
         $newCollection[$gameKey]['servers'][] = $server;
     }
     foreach ($newCollection as $key => $collection) {
         $online = 0;
         $total = 0;
         foreach ($collection['servers'] as $server) {
             $online += $server->usedSlots;
             $total += $server->maxSlots;
         }
         $newCollection[$key]['stats'] = ['online' => $online, 'totalSlots' => $total, 'percentage' => MainHelper::percent($online, $total)];
     }
     return MainHelper::response(['online' => $usedSlots, 'totalSlots' => $totalSlots, 'percentage' => MainHelper::percent($usedSlots, $totalSlots), 'games' => $newCollection] + Lang::get('dashboard.population'), null, null, null, false, true);
 }
Exemplo n.º 2
0
 /**
  * Gets the player weapon stats
  *
  * @return array
  */
 public function getWeaponStats()
 {
     // Generate URI for request
     $uri = sprintf($this->uris[$this->game]['weapons'], $this->game, $this->personaID);
     // Send request
     $results = $this->sendRequest($uri)['data'];
     // Create weapons array
     $weapons = new Collection();
     // Loop over the weapons and add them to the weapons array
     foreach ($results['mainWeaponStats'] as $weapon) {
         if ($this->game == 'bf3') {
             $weaponURI = sprintf('%s/soldier/%s/iteminfo/%s/%u/pc/', $this->game, $this->player->SoldierName, strtolower($weapon['slug']), $this->personaID);
         } else {
             $weaponURI = sprintf('%s/soldier/%s/weapons/%u/pc/#%s', $this->game, $this->player->SoldierName, $this->personaID, strtolower($weapon['slug']));
         }
         $weapons->push(['slug' => $weapon['slug'], 'category' => $weapon['category'], 'headshots' => $weapon['headshots'], 'kills' => $weapon['kills'], 'deaths' => $weapon['deaths'], 'score' => $weapon['score'], 'fired' => $weapon['shotsFired'], 'hit' => $weapon['shotsHit'], 'timeEquipped' => $weapon['timeEquipped'], 'accuracy' => MainHelper::percent($weapon['shotsHit'], $weapon['shotsFired']), 'kpm' => MainHelper::divide($weapon['kills'], MainHelper::divide($weapon['timeEquipped'], 60)), 'hskp' => MainHelper::percent($weapon['headshots'], $weapon['kills']), 'dps' => MainHelper::percent($weapon['kills'], $weapon['shotsHit']), 'weapon_link' => parent::BLOG . $weaponURI]);
     }
     return $weapons;
 }
Exemplo n.º 3
0
 /**
  * Calculates how full the server is represented by a percentage
  *
  * @return float
  */
 public function getPercentageAttribute()
 {
     return MainHelper::percent($this->usedSlots, $this->maxSlots);
 }