Example #1
0
 public function getLightLeaderboard()
 {
     $pandas = Account::with('destiny.characters')->whereHas('destiny', function ($query) {
         $query->where('clanName', 'Panda Love')->where('clanTag', 'WRKD')->where('inactiveCounter', '<', 10);
     })->get();
     $p = [];
     Hashes::cacheAccountsHashes($pandas);
     foreach ($pandas as $panda) {
         $character = $panda->destiny->highestLevelHighestLight();
         $p[$character->level][] = ['name' => $panda->gamertag . " (" . $character->class->title . ")", 'maxLight' => $character->highest_light, 'light' => $character->light];
     }
     krsort($p);
     foreach ($p as $key => $value) {
         // lets sort the sub levels
         usort($value, function ($a, $b) {
             return $b['maxLight'] - $a['maxLight'];
         });
         $p[$key] = $value;
     }
     $msg = '<strong>Light Leaderboard</strong><br /><br />';
     foreach ($p as $level => $chars) {
         $msg .= "<strong>Level " . $level . "'s</strong><br />";
         $i = 1;
         foreach ($chars as $char) {
             $msg .= $i . ". " . $char['name'] . " <strong>" . $char['maxLight'] . "</strong><br />";
             $i++;
         }
         $msg .= '<br />';
     }
     return Response::json(['error' => false, 'msg' => $msg], 200);
 }
Example #2
0
 /**
  * @param string $index Index for $this->attributes
  * @param string $hash hashCode for item
  * @throws \Onyx\Destiny\Helpers\String\HashNotLocatedException
  */
 private function setAttributePullImage($index, $hash)
 {
     if ($hash == null || $hash == "") {
         return;
     }
     Images::saveImagesLocally($this->translator->map($hash, false));
     $this->attributes[$index] = $hash;
 }
Example #3
0
 public function getIndex()
 {
     $accounts = Account::with('destiny.characters')->whereHas('destiny', function ($query) {
         $query->where('clanName', 'Panda Love');
     })->orderBy('gamertag', 'ASC')->paginate(15);
     // attempt hash cache
     Hashes::cacheAccountsHashes($accounts);
     return view('destiny.roster', ['members' => $accounts, 'description' => 'PandaLove Destiny Roster page', 'title' => 'PandaLove Destiny Roster']);
 }
 public function index($gamertag = '', $characterId = '')
 {
     try {
         $account = Account::with('destiny.characters')->where('seo', Text::seoGamertag($gamertag))->firstOrFail();
         $games = GamePlayer::with('game')->select('game_players.*', 'games.occurredAt')->leftJoin('games', 'game_players.game_id', '=', 'games.instanceId')->where('membershipId', $account->destiny->membershipId)->where('deaths', 0)->where('games.instanceId', '!=', 0)->orderBy('games.occurredAt', 'DESC')->get();
         $games->each(function ($game_player) {
             $game_player->url = $game_player->game->buildUrl();
         });
         // setup hash cache
         Hashes::cacheAccountHashes($account, $games);
         return view('destiny.profile', ['account' => $account, 'games' => $games, 'characterId' => $account->destiny->characterExists($characterId) ? $characterId : false, 'description' => ($account->isPandaLove() ? "PandaLove: " : null) . $account->gamertag . " Destiny Profile", 'title' => $account->gamertag . ($account->isPandaLove() ? " (Panda Love Member)" : null)]);
     } catch (ModelNotFoundException $e) {
         \App::abort(404, 'Da Gone!!! We have no idea what you are looking for.');
     }
 }
Example #5
0
 public static function buildQuickPassageStats($games)
 {
     $combined = [];
     $combined['stats'] = ['pandaPts' => 0, 'opponentPts' => 0, 'pandaWins' => 0, 'opponentWins' => 0, 'totalGames' => 0, 'blowoutGames' => 0, 'differentMaps' => false];
     $combined['buffs'] = ['favor' => false, 'mercy' => false, 'boon' => false, 'boon-or-favor' => false, 'quitout' => 0];
     $previous = null;
     $maps = new Collection();
     foreach ($games as $game) {
         $pandaId = $game->pvp->pandaId;
         $opponentId = $game->pvp->opposite($pandaId);
         if ($maps->has($game->referenceId)) {
             $count = $maps->get($game->referenceId);
             $maps->forget($game->referenceId);
             $maps->put($game->referenceId, ++$count);
         } else {
             $maps->put($game->referenceId, 1);
         }
         $combined['stats']['pandaPts'] += $game->pvp->pts($pandaId);
         $combined['stats']['opponentPts'] += $game->pvp->pts($opponentId);
         $combined['stats']['pandaWins'] += $pandaId == $game->pvp->winnerId ? 1 : 0;
         $combined['stats']['opponentWins'] += $opponentId == $game->pvp->winnerId ? 1 : 0;
         $combined['stats']['totalGames'] += 1;
         // Check if PandaLove blew them out (15 - 0)
         // Update: Trials #2 maxes at 5-0
         // Update: Forget max, just check if enemy got 0pts
         if ($pandaId == $game->pvp->winnerId) {
             if ($game->pvp->pts($opponentId) == 0) {
                 $combined['stats']['blowoutGames'] += 1;
             }
         }
         if ($previous == null) {
             $previous = $game->referenceId;
         } else {
             if ($previous != $game->referenceId) {
                 $combined['stats']['differentMaps'] = true;
             }
         }
         foreach ($game->players as $player) {
             $id = $player->account->membershipId;
             if ($player->account->isPandaLove() || $player->team == $pandaId) {
                 // check for unbroken
                 if ($player->deaths == 0) {
                     if (isset($combined['stats']['unbroken'][$id])) {
                         $combined['stats']['unbroken'][$id]['count'] += 1;
                     } else {
                         $combined['stats']['unbroken'][$id] = ['gamertag' => $player->account->gamertag, 'seo' => $player->account->seo, 'count' => 1];
                     }
                 }
             }
         }
     }
     // are we on different maps? If so lets get the names of them
     if ($combined['stats']['differentMaps']) {
         $map_list = '';
         $new_maps = null;
         $maps->each(function ($count, $map) use(&$map_list, &$new_maps) {
             $map_list .= Hashes::quick($map)['title'] . ", ";
         });
         $combined['stats']['maps'] = rtrim($map_list, ", ");
         $new_maps = $maps->toArray();
         arsort($new_maps);
         $combined['stats']['rMaps'] = $new_maps;
     }
     $bonus = 0;
     if ($combined['stats']['pandaWins'] < 7) {
         $combined['buffs']['quitout'] = 7 - $combined['stats']['pandaWins'];
         $bonus += $combined['buffs']['quitout'];
     }
     // Lets check for Boon/Mercy/Favor of Osiris
     if ($combined['stats']['pandaWins'] != $combined['stats']['totalGames']) {
         // Our Panda # of wins does not equal total games, therefore a loss was encountered
         $combined['buffs']['mercy'] = true;
     }
     if ($combined['stats']['pandaWins'] == 8 - $bonus) {
         // We have 8 wins. This means the group could of either used a Boon (First win = two wins)
         // or a Favor (start with 1 win).
         $combined['buffs']['boon-or-favor'] = true;
     }
     if ($combined['stats']['pandaWins'] == 7 - $bonus) {
         // We have 7 wins. That means both the Boon and Favor was used.
         $combined['buffs']['favor'] = true;
         $combined['buffs']['boon'] = true;
     }
     return $combined;
 }
Example #6
0
 private function getItems()
 {
     Hashes::$items = Hash::all();
     return Hashes::$items;
 }
Example #7
0
 public function getHistory($category = '')
 {
     $raids = null;
     $title = 'Raid';
     $description = '';
     $p = $this->isPanda;
     switch ($category) {
         case "Raid":
             $description = 'Raids';
             $raids = Game::raid($p)->singular()->with('players.historyAccount')->paginate(10);
             break;
         case "Flawless":
             $description = 'Flawless Raids';
             $raids = Game::flawless($p)->singular()->with('players.historyAccount')->paginate(10);
             break;
         case "RaidTuesdays":
             $description = 'Raid Tuesdays';
             $raids = Game::tuesday($p)->with('players.historyAccount')->paginate(10);
             break;
         case "PVP":
             $description = 'PVP';
             $title = 'Gametype';
             $raids = Game::multiplayer($p)->singular()->with('players.historyAccount', 'pvp')->paginate(10);
             break;
         case "PoE":
             $description = 'Prison Of Elders';
             $raids = Game::poe($p)->singular()->with('players.historyAccount')->paginate(10);
             break;
         case "ToO":
             $description = 'Trials Of Osiris';
             $title = 'Gametype';
             $raids = Game::passage()->with('players.historyAccount')->paginate(10);
             break;
         default:
             \App::abort(404);
             break;
     }
     Hashes::cacheHistoryHashes($raids);
     return view('destiny.games.history')->with('raids', $raids)->with('t_header', $title)->with('title', 'PandaLove: ' . $description . ' History')->with('description', 'PandaLove complete history of: ' . $description);
 }
Example #8
0
 /**
  * @return bool
  * @throws Helpers\Network\BungieOfflineException
  */
 public function getXurData()
 {
     $key = 'xur';
     if (Cache::has($key)) {
         return Cache::get($key);
     } else {
         $url = Constants::$xurData;
         $json = $this->getJson($url);
         if (!isset($json['Response']['data'])) {
             return false;
             // no xur data
         } else {
             $translator = new Hashes();
             $translator->setUrl($url);
             $items = '<strong>Xur Items</strong><br/><br />';
             foreach ($json['Response']['data']['saleItemCategories'] as $category) {
                 if ($category['categoryTitle'] == "Exotic Gear") {
                     foreach ($category['saleItems'] as $item) {
                         if (isset($item['item']['stats']) && count($item['item']['stats']) > 0) {
                             $items .= "<strong>" . $translator->map($item['item']['itemHash'], true) . '</strong>' . ' - <a href="' . $this->getItemUrl($item['item']['itemHash']) . '">url' . '</a><br />';
                             foreach ($item['item']['stats'] as $stat) {
                                 if ($stat['value'] != 0) {
                                     $items .= '  -->' . $translator->map($stat['statHash'], true) . ": " . number_format($stat['value']) . "<br />";
                                 }
                             }
                             $items .= '<br />';
                         }
                     }
                 }
             }
             Cache::put($key, $items, 120);
             return $items;
         }
     }
 }