]> git.localhorst.tv Git - alttp.git/commitdiff
accept case insensitive presets over api
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 28 May 2022 15:47:47 +0000 (17:47 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 28 May 2022 15:47:47 +0000 (17:47 +0200)
app/DiscordAppCommands/AosrPresetCommand.php
app/Http/Controllers/AosSeedController.php

index 5ad05e00b0628c87145b467fa16a3c6a52d0e1ef..7a8907a419c87b3258ded2761bed28144de30380 100644 (file)
@@ -54,6 +54,18 @@ class AosrPresetCommand {
                $discord->application->commands->save($cmd);
        }
 
+       public static function presetByName($name) {
+               if (isset(static::$presets[$name])) {
+                       return static::$presets[$name];
+               }
+               foreach (static::$presets as $presetName => $preset) {
+                       if (strcasecmp($name, $presetName) === 0) {
+                               return $preset;
+                       }
+               }
+               return null;
+       }
+
        public static function listen(Discord $discord) {
                $discord->listenCommand(['aosr', 'preset'], function(Interaction $interaction) use ($discord) {
                        $interaction
index 1e2aa73a91b637a07d223cacfa4fb3b729249d2e..19f6f4b6b0c6094a6b9a0e5dbe6d07d9107a926a 100644 (file)
@@ -31,10 +31,10 @@ class AosSeedController extends Controller
                $presetName = $validatedData['preset'];
                $race = $validatedData['race'] ?? false;
 
-               if (!isset(AosrPresetCommand::$presets[$presetName])) {
+               $preset = AosrPresetCommand::presetByName($presetName);
+               if (!$preset) {
                        abort(404);
                }
-               $preset = AosrPresetCommand::$presets[$presetName];
                $seed = AosSeed::generateSurge($presetName, $preset['settings'], $race);
                Artisan::call('aos:generate '.intval($seed->id));