2 function filterByAge($origGames, $age)
5 foreach ($origGames as $game) {
6 if ($age == $game->contentRating) {
13 function filterByGenre($origGames, $genre, $remove = false)
16 foreach ($origGames as $game) {
18 if (array_search($genre, $game->genres) === false) {
22 if (array_search($genre, $game->genres) !== false) {
30 function filterByLetter($origGames, $letter)
33 foreach ($origGames as $game) {
34 $gameLetter = strtoupper($game->title{0});
35 if (!preg_match('#^[A-Z]$#', $gameLetter)) {
36 $gameLetter = 'Other';
38 if ($letter == $gameLetter) {
45 function filterByPackageNames($origGames, $packageNames)
47 $names = array_flip($packageNames);
49 foreach ($origGames as $game) {
50 if (isset($names[$game->packageName])) {
57 function filterByPlayers($origGames, $numOfPlayers)
60 foreach ($origGames as $game) {
61 if (array_search($numOfPlayers, $game->players) !== false) {
68 function filterBySearchWord($origGames, $searchWord)
71 foreach ($origGames as $game) {
72 if (stripos($game->title, $searchWord) !== false) {
79 function filterLastUpdated($origGames, $limit)
81 $games = array_values($origGames);
84 function ($gameA, $gameB) {
85 return strtotime($gameB->latestRelease->date) - strtotime($gameA->latestRelease->date);
89 return array_slice($games, 0, $limit);
92 function filterBestRated($origGames, $limit)
94 $games = array_values($origGames);
97 function ($gameA, $gameB) {
98 return ($gameB->rating->rank - $gameA->rating->rank) * 100;
102 return array_slice($games, 0, $limit);
105 function filterMostDownloaded($origGames, $limit)
107 $games = array_values($origGames);
110 function ($gameA, $gameB) {
111 return $gameB->rating->count - $gameA->rating->count;
115 return array_slice($games, 0, $limit);
118 function filterRandom($origGames, $limit)
120 $randKeys = array_rand($origGames, $limit);
122 foreach ($randKeys as $key) {
123 $games[] = $origGames[$key];
128 function sortByTitle($games)
132 function ($gameA, $gameB) {
133 return strcasecmp($gameA->title, $gameB->title);