namespace App\Http\Controllers;
+use App\DiscordAppCommands\AosrPresetCommand;
use App\Models\AosSeed;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
return $seed->toJson();
}
+ public function generate(Request $request) {
+ $validatedData = $request->validate([
+ 'preset' => 'string|required',
+ 'race' => 'boolean',
+ ]);
+ $presetName = $validatedData['preset'];
+ $race = $validatedData['race'] ?? false;
+
+ if (!isset(AosrPresetCommand::$presets[$presetName])) {
+ abort(404);
+ }
+ $preset = AosrPresetCommand::$presets[$presetName];
+ $seed = AosSeed::generateSurge($presetName, $preset['settings'], $race);
+ Artisan::call('aos:generate '.intval($seed->id));
+
+ $seed = $this->censor($seed->fresh());
+ return $seed->toJson();
+ }
+
public function retry($hash) {
$seed = AosSeed::where('hash', '=', $hash)->firstOrFail();
Artisan::call('aos:generate '.intval($seed->id));
}
+ $seed = $this->censor($seed->fresh());
return $seed->toJson();
}
+ private function censor(AosSeed $seed) {
+ if ($seed->race) {
+ $seed->makeHidden('seed');
+ }
+ if ($seed->mystery) {
+ $seed->makeHidden('settings');
+ }
+ return $seed;
+ }
+
}
Route::get('alttp-seed/{hash}', 'App\Http\Controllers\AlttpSeedController@byHash');
Route::post('alttp-seed/{hash}/retry', 'App\Http\Controllers\AlttpSeedController@retry');
+Route::post('aos-generate', 'App\Http\Controllers\AosSeedController@generate');
Route::get('aos-seed/{hash}', 'App\Http\Controllers\AosSeedController@byHash');
Route::post('aos-seed/{hash}/retry', 'App\Http\Controllers\AosSeedController@retry');