diff --git a/Website/www/games/arksa/breeding.php b/Website/www/games/arksa/breeding.php index 2d1d8a4fe..f7d5fa93c 100644 --- a/Website/www/games/arksa/breeding.php +++ b/Website/www/games/arksa/breeding.php @@ -10,12 +10,15 @@ $ism = isset($_GET['ism']) ? floatval($_GET['ism']) : 1.0; $iam = isset($_GET['iam']) ? floatval($_GET['iam']) : 1.0; -$steamIds = []; +$contentPackIds = []; +$curseForgeIds = []; $m = isset($_GET['m']) ? explode(',', $_GET['m']) : []; for ($idx = 0; $idx < count($m); $idx++) { $id = filter_var($m[$idx], FILTER_VALIDATE_INT); if ($id !== false) { - $steamIds[] = $id; + $curseForgeIds[] = $id; + } elseif (BeaconCommon::IsUUID($m[$idx])) { + $contentPackIds[] = $m[$idx]; } } @@ -25,16 +28,55 @@ $iam = ($iam > 0) ? $iam : 1.0; $database = BeaconCommon::Database(); +$results = $database->Query('SELECT MAX(build_number) AS newest_build FROM updates;'); +$minVersion = $results->Field('newest_build'); + +$officialPacks = ContentPack::Search(['minVersion' => $minVersion, 'isOfficial' => true], true); +foreach ($officialPacks as $officialPack) { + $contentPackIds[] = $officialPack->ContentPackId(); +} + +$marketplacePacks = ContentPack::Search(['minVersion' => $minVersion, 'marketplace' => 'CurseForge', 'marketplaceId' => implode(',', $curseForgeIds)], true); +foreach ($marketplacePacks as $marketplacePack) { + $contentPackIds[] = $marketplacePack->ContentPackId(); +} + +$results = $database->Query('SELECT MAX(EXTRACT(EPOCH FROM last_update)) AS last_update FROM public.content_update_times WHERE min_version <= $1 AND content_pack_id = ANY($2);', $minVersion, '{' . implode(',', $contentPackIds) . '}'); +$lastUpdate = $results->Field('last_update'); + +$cacheKey = md5('arksa.breeding:' . $lastUpdate . ';msm=' . number_format($msm, 8) . ';ipm=' . number_format($ipm, 8) . ';ism=' . number_format($ism, 8) . ';iam=' . number_format($iam, 8) . ';m=' . implode(',', $contentPackIds)); +if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { + $tags = explode(',', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])); + $validMatches = ['"' . $cacheKey . '"', 'W/"' . $cacheKey . '"']; + foreach ($tags as $tag) { + $tag = trim($tag); + if (in_array($tag, $validMatches)) { + http_response_code(304); + header('Content-Type: text/plain'); + exit; + } + } +} + +header('ETag: "' . $cacheKey . '"'); +BeaconTemplate::AddStylesheet(BeaconCommon::AssetURI('breeding.css')); + +$cached = BeaconCache::Get($cacheKey); +if (is_null($cached) === false) { + echo $cached; + exit; +} + $results = $database->Query('SELECT value::INTEGER FROM arksa.game_variables WHERE key = $1;', 'Cuddle Period'); if ($results->RecordCount() != 1) { http_response_code(500); echo "There was a problem loading the default imprint interval."; exit; } -$official_cuddle_period = $results->Field('value'); -$computed_cuddle_period = round($official_cuddle_period * $ipm); +$officialCuddlePeriod = $results->Field('value'); +$computedCuddlePeriod = round($officialCuddlePeriod * $ipm); -BeaconTemplate::AddStylesheet(BeaconCommon::AssetURI('breeding.css')); +ob_start(); ?>
' . $label . ' Incubation Time: ' . htmlentities($incubation_text) . ' Mature Time: ' . htmlentities($mature_text) . ' Imprinting: ' . htmlentities($cuddle_text) . ' | ' . htmlentities($incubation_text) . ' | ' . htmlentities($mature_text) . ' | ' . htmlentities($cuddle_text) . ' |
' . $label . ' Incubation Time: ' . htmlentities($incubationText) . ' Mature Time: ' . htmlentities($matureText) . ' Imprinting: ' . htmlentities($cuddleText) . ' | ' . htmlentities($incubationText) . ' | ' . htmlentities($matureText) . ' | ' . htmlentities($cuddleText) . ' |
Any creature that can be imprinted can be imprinted to 100%
+Any creature that can be imprinted can be imprinted to 100%