$games = [];
$count = 0;
$developers = [];
+
+//load game data. doing early to collect a developer's games
foreach ($gameFiles as $gameFile) {
$game = json_decode(file_get_contents($gameFile));
if ($game === null) {
addMissingGameProperties($game);
$games[$game->packageName] = $game;
- writeJson(
- 'api/v1/details-data/' . $game->packageName . '.json',
- buildDetails($game)
- );
-
if (!isset($developers[$game->developer->uuid])) {
$developers[$game->developer->uuid] = [
- 'info' => $game->developer,
- 'products' => [],
+ 'info' => $game->developer,
+ 'products' => [],
+ 'gameNames' => [],
];
}
+ $developers[$game->developer->uuid]['gameNames'][] = $game->packageName;
+}
+//write json api files
+foreach ($games as $game) {
$products = $game->products ?? [];
foreach ($products as $product) {
writeJson(
$developers[$game->developer->uuid]['products'][] = $product;
}
- /**/
+ writeJson(
+ 'api/v1/details-data/' . $game->packageName . '.json',
+ buildDetails(
+ $game,
+ count($developers[$game->developer->uuid]['gameNames']) > 1
+ )
+ );
+
writeJson(
'api/v1/games/' . $game->packageName . '/purchases',
buildPurchases($game)
buildDeveloperProducts($developer['products'], $developer['info'])
);
writeJson(
- //index.htm does not need a rewrite rule
'api/v1/developers/' . $developer['info']->uuid
. '/current_gamer',
buildDeveloperCurrentGamer()
);
+
+ if (count($developer['gameNames']) > 1) {
+ writeJson(
+ 'api/v1/discover-data/dev--' . $developer['info']->uuid . '.json',
+ buildSpecialCategory(
+ 'Developer: ' . $developer['info']->name,
+ filterByPackageNames($games, $developer['gameNames'])
+ )
+ );
+ }
}
writeJson('api/v1/discover-data/discover.json', buildDiscover($games));
);
addDiscoverRow(
$data, 'Best rated',
- filterBestRated($games, 10)
+ filterBestRated($games, 10),
+ true
);
foreach ($GLOBALS['packagelists'] as $listTitle => $listPackageNames) {
);
addDiscoverRow(
$data, 'Best rated',
- filterBestRated($games, 10)
+ filterBestRated($games, 10),
+ true
);
$games = sortByTitle($games);
return $data;
}
+/**
+ * Category without the "Last updated" or "Best rated" top rows
+ *
+ * Used for "Best rated", "Most rated", "Random"
+ */
function buildSpecialCategory($name, $games)
{
$data = [
function buildDiscoverHome(array $games)
{
- //we do not want anything here for now
$data = [
'title' => 'home',
'rows' => [
- [
- 'title' => 'FEATURED',
- 'showPrice' => false,
- 'ranked' => false,
- 'tiles' => [],
- ]
],
'tiles' => [],
];
+
+ if (isset($GLOBALS['home'])) {
+ reset($GLOBALS['home']);
+ $title = key($GLOBALS['home']);
+ addDiscoverRow(
+ $data, $title,
+ filterByPackageNames($games, $GLOBALS['home'][$title])
+ );
+ } else {
+ $data['rows'][] = [
+ 'title' => 'FEATURED',
+ 'showPrice' => false,
+ 'ranked' => false,
+ 'tiles' => [],
+ ];
+ }
+
return $data;
}
/**
* Build /app/v1/details?app=org.example.game
*/
-function buildDetails($game)
+function buildDetails($game, $linkDeveloperPage = false)
{
$latestRelease = $game->latestRelease;
}
// http://cweiske.de/ouya-store-api-docs.htm#get-https-devs-ouya-tv-api-v1-details
- return [
+ $data = [
'type' => 'Game',
'title' => $game->title,
'description' => $game->description,
'developer-url' => $game->developer->website ?? null,
]
];
+
+ if ($linkDeveloperPage) {
+ $data['developer']['url'] = 'ouya://launcher/discover/dev--'
+ . categoryPath($game->developer->uuid);
+ }
+
+ return $data;
}
function buildDeveloperCurrentGamer()
*/
function buildDeveloperProducts($products, $developer)
{
+ //remove duplicates
+ $products = array_values(array_column($products, null, 'identifier'));
+
$jsonProducts = [];
foreach ($products as $product) {
$jsonProducts[] = buildProduct($product);
}
}
-function addDiscoverRow(&$data, $title, $games)
+function addDiscoverRow(&$data, $title, $games, $ranked = false)
{
$row = [
'title' => $title,
'showPrice' => true,
- 'ranked' => false,
+ 'ranked' => $ranked,
'tiles' => [],
];
foreach ($games as $game) {