X-Git-Url: https://git.cweiske.de/stouyapi.git/blobdiff_plain/ad9f3cf5a07338134a29fee4b6215c50cb8142c8..eb1adeed23d43d79841c123a9c34e4ea5c6ed2ce:/bin/filters.php diff --git a/bin/filters.php b/bin/filters.php index 628936a..a10777a 100644 --- a/bin/filters.php +++ b/bin/filters.php @@ -102,6 +102,29 @@ function filterBestRated($origGames, $limit) return array_slice($games, 0, $limit); } +function filterMostDownloaded($origGames, $limit) +{ + $games = array_values($origGames); + usort( + $games, + function ($gameA, $gameB) { + return $gameB->rating->count - $gameA->rating->count; + } + ); + + return array_slice($games, 0, $limit); +} + +function filterRandom($origGames, $limit) +{ + $randKeys = array_rand($origGames, $limit); + $games = []; + foreach ($randKeys as $key) { + $games[] = $origGames[$key]; + } + return $games; +} + function sortByTitle($games) { usort(