Styling fixes and Olden Era mmodule
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\TwitchHelix;
|
||||
use App\Support\OldenEra;
|
||||
use App\Support\RigData;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,13 +19,19 @@ use Throwable;
|
||||
*/
|
||||
class OnboardController extends Controller
|
||||
{
|
||||
public function show(RigData $rig, TwitchHelix $twitch)
|
||||
public function show(RigData $rig, TwitchHelix $twitch, OldenEra $olden)
|
||||
{
|
||||
return view('onboard', [
|
||||
'manifest' => $rig->loading(),
|
||||
'telemetry' => $rig->telemetry(),
|
||||
'trackCount' => $rig->playlistCount(),
|
||||
'twitchEnabled' => $twitch->enabled(),
|
||||
'oldenEra' => [
|
||||
'gameId' => OldenEra::GAME_ID,
|
||||
'assetBase' => OldenEra::URL,
|
||||
'catalog' => $olden->catalog(),
|
||||
'manifest' => $olden->manifest(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -47,7 +54,7 @@ class OnboardController extends Controller
|
||||
return response()->json(['matches' => $hits]);
|
||||
}
|
||||
|
||||
public function submit(Request $request, RigData $rig, TwitchHelix $twitch): JsonResponse
|
||||
public function submit(Request $request, RigData $rig, TwitchHelix $twitch, OldenEra $olden): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'game' => 'required|string|max:200',
|
||||
@@ -76,6 +83,28 @@ class OnboardController extends Controller
|
||||
json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n"
|
||||
);
|
||||
|
||||
$oldenPath = null;
|
||||
if (($manifest['gameId'] ?? null) === OldenEra::GAME_ID) {
|
||||
$factions = array_keys($olden->catalog());
|
||||
$extra = $request->validate([
|
||||
'olden.color' => 'required|in:red,blue',
|
||||
'olden.my.faction' => 'required|string|in:' . implode(',', $factions),
|
||||
'olden.my.hero' => 'required|string|max:120',
|
||||
'olden.enemy.faction' => 'required|string|in:' . implode(',', $factions),
|
||||
'olden.enemy.hero' => 'required|string|max:120',
|
||||
'olden.map' => 'nullable|string|max:200',
|
||||
])['olden'];
|
||||
|
||||
$oldenPath = $olden->writeManifest([
|
||||
'compiledAt' => gmdate('Y-m-d\TH:i:s\Z'),
|
||||
'gameId' => OldenEra::GAME_ID,
|
||||
'color' => $extra['color'],
|
||||
'my' => $extra['my'],
|
||||
'enemy' => $extra['enemy'],
|
||||
'map' => isset($extra['map']) && $extra['map'] !== '' ? $extra['map'] : null,
|
||||
]);
|
||||
}
|
||||
|
||||
$twitchStatus = null;
|
||||
if (!empty($data['pushTwitch']) && $twitch->enabled() && !empty($manifest['gameId'])) {
|
||||
try {
|
||||
@@ -88,10 +117,11 @@ class OnboardController extends Controller
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'manifest' => $manifest,
|
||||
'twitch' => $twitchStatus,
|
||||
'path' => str_replace(base_path() . '/', '', $path),
|
||||
'ok' => true,
|
||||
'manifest' => $manifest,
|
||||
'twitch' => $twitchStatus,
|
||||
'path' => str_replace(base_path() . '/', '', $path),
|
||||
'oldenPath' => $oldenPath ? str_replace(base_path() . '/', '', $oldenPath) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user