/**
  * Section that lists all games and individual game stats
  */
 public function actionGames()
 {
     $sHelper = new Steam_Helper_Steam();
     $gameId = $this->_input->filterSingle('game_id', XenForo_Input::UINT);
     if ($gameId) {
         $userModel = XenForo_Model::create('XenForo_Model_User');
         $sHelper = new Steam_Helper_Steam();
         $users = $sHelper->getGameOwners($gameId);
         $owners = array();
         $hours = 0;
         foreach ($users as $user) {
             $u = $userModel->getUserById($user['user_id']);
             $user['avatar_url'] = XenForo_Template_Helper_Core::callHelper('avatar', array($u, 's', null, true));
             $owners[] = $user;
             $hours += $user['hours'];
         }
         if (count($owners) == 0) {
             $hoursAvgMath = 0;
         } else {
             $hoursAvgMath = round($hours / count($owners));
         }
         $viewParams = array('count' => count($owners), 'game' => $sHelper->getGameInfo($gameId), 'users' => $owners, 'hours' => $hours, 'hoursAvg' => $hoursAvgMath);
         $template = 'steam_stats_game_view';
     } else {
         $steamModel = new Steam_Model_Steam();
         $gamesPerPage = 25;
         $page = $this->_input->filterSingle('page', XenForo_Input::UINT);
         $viewParams = array('page' => $page, 'totalGames' => $sHelper->getAvailableGamesCount(), 'gamesPerPage' => $gamesPerPage, 'games' => $steamModel->getAvailableGames(array('perPage' => $gamesPerPage, 'page' => $page)));
         $template = 'steam_stats_games';
     }
     return $this->responseView('XenForo_ViewAdmin_Steam_Games', $template, $viewParams);
 }