]> git.localhorst.tv Git - alttp.git/blobdiff - app/DiscordAppCommands/AosrPresetCommand.php
remove aosr command
[alttp.git] / app / DiscordAppCommands / AosrPresetCommand.php
index 6c694caf26677a4c980ef06d046f6f7387788003..e4d0fbb529ddf08c0eab8756f2fef82fa0d791f2 100644 (file)
@@ -5,9 +5,6 @@ namespace App\DiscordAppCommands;
 use App\Models\AosSeed;
 use Discord\Builders\MessageBuilder;
 use Discord\Discord;
-use Discord\Parts\Embed\Embed;
-use Discord\Parts\Embed\Field;
-use Discord\Parts\Embed\Footer;
 use Discord\Parts\Interactions\Interaction;
 
 class AosrPresetCommand {
@@ -57,6 +54,29 @@ class AosrPresetCommand {
                $discord->application->commands->save($cmd);
        }
 
+       public static function delete(Discord $discord) {
+               $discord->application->commands->freshen()->then(function () use ($discord) {
+                       $cmd = $discord->application->commands->find(function ($cmd) {
+                               return $cmd->name == 'aosr';
+                       });
+                       if ($cmd) {
+                               $discord->application->commands->delete($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
@@ -65,41 +85,33 @@ class AosrPresetCommand {
                                $presetName = $interaction->data->options['preset']->options['preset']->value;
                                $race =  isset($interaction->data->options['preset']->options['race'])
                                        ? $interaction->data->options['preset']->options['race']->value : false;
-                               $message = MessageBuilder::new();
                                if (isset(static::$presets[$presetName])) {
                                        $preset = static::$presets[$presetName];
                                        $seed = AosSeed::generateSurge($presetName, $preset['settings'], $race);
 
-                                       $embed = new Embed($discord, [
-                                               'fields' => [
-                                                       new Field($discord, [ 'name' => 'Generator', 'value' => 'This seed has been generated with fusecv\'s randomizer on aosrando.surge.sh.' ]),
-                                                       new Field($discord, [ 'name' => 'Preset', 'value' => $preset['name'], 'inline' => true ]),
-                                                       new Field($discord, [ 'name' => 'Seed', 'value' => $race ? 'secret' : $seed->seed, 'inline' => true ]),
-                                                       new Field($discord, [ 'name' => 'Logic', 'value' => $preset['settings']['logic'], 'inline' => true ]),
-                                                       new Field($discord, [ 'name' => 'Area', 'value' => $preset['settings']['area'], 'inline' => true ]),
-                                                       new Field($discord, [ 'name' => 'Boss', 'value' => $preset['settings']['boss'], 'inline' => true ]),
-                                                       new Field($discord, [ 'name' => 'Enemy', 'value' => $preset['settings']['enemy'], 'inline' => true ]),
-                                                       new Field($discord, [ 'name' => 'Permalink', 'value' => $seed->permalink ]),
-                                               ],
-                                               'footer' => new Footer($discord, [
-                                                       'text' => 'GrĂ¼n',
-                                               ]),
-                                               'timestamp' => now(),
-                                               'title' => 'AoSRando Seed',
-                                               'type' => 'rich',
-                                               'url' => $seed->permalink,
-                                       ]);
-                                       $message->addEmbed($embed);
+                                       $process = $seed->createProcess();
+                                       $process->on('exit', function() use ($discord, $interaction, $seed) {
+                                               $seed = $seed->fresh();
+
+                                               $embed = $seed->createEmbed($discord);
+                                               $message = MessageBuilder::new();
+                                               $message->addEmbed($embed);
+
+                                               $interaction->updateOriginalResponse($message);
+                                       });
+
+                                       $process->start($discord->getLoop());
                                } else {
+                                       $message = MessageBuilder::new();
                                        $message->setContent('unknown preset '.$presetName);
+                                       $interaction->updateOriginalResponse($message);
                                }
-                               $interaction->updateOriginalResponse($message);
                        });
                        return true;
                });
        }
 
-       private static $presets = [
+       public static $presets = [
                'Normal' => [
                        'name' => 'Normal',
                        'value' => 'Normal',
@@ -121,6 +133,8 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -145,6 +159,8 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'true',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -169,6 +185,8 @@ class AosrPresetCommand {
                                'telestart' => 'true',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -193,6 +211,8 @@ class AosrPresetCommand {
                                'telestart' => 'true',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -217,6 +237,8 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -241,6 +263,8 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'true',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -265,6 +289,8 @@ class AosrPresetCommand {
                                'telestart' => 'true',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -289,6 +315,8 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -313,6 +341,8 @@ class AosrPresetCommand {
                                'telestart' => 'true',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -337,6 +367,34 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'true',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'AreaRequireAllSouls' => [
+                       'name' => 'Area require all souls',
+                       'value' => 'AreaRequireAllSouls',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'true',
+                               'panther' => 'NeverExists',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'RandomNoLimit',
+                               'itempool' => 'Standard',
+                               'weight' => '2.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'true',
+                               'startshop' => 'Vanilla',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => 'Half',
+                               'levelexp' => 'Lvl1',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'true',
+                               'reqallsouls' => 'true',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -361,6 +419,8 @@ class AosrPresetCommand {
                                'telestart' => 'true',
                                'mapassist' => 'true',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -385,6 +445,8 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -409,16 +471,18 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
-               'SGLive2021' => [
-                       'name' => 'SGLive 2021',
-                       'value' => 'SGLive2021',
+               'Tournament2021' => [
+                       'name' => 'Tournament 2021',
+                       'value' => 'Tournament2021',
                        'settings' => [
                                'logic' => 'AreaTechTiers',
                                'nodupes' => 'false',
-                               'panther' => 'FirstAlways',
+                               'panther' => 'Rand70Dup',
                                'area' => 'AreaRandom',
                                'boss' => 'Dead-endShuffle',
                                'enemy' => 'Vanilla',
@@ -433,16 +497,18 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
-               'Tournament2021' => [
-                       'name' => 'Tournament 2021',
-                       'value' => 'Tournament2021',
+               'SGLive2021' => [
+                       'name' => 'SGLive 2021',
+                       'value' => 'SGLive2021',
                        'settings' => [
                                'logic' => 'AreaTechTiers',
                                'nodupes' => 'false',
-                               'panther' => 'Rand70Dup',
+                               'panther' => 'FirstAlways',
                                'area' => 'AreaRandom',
                                'boss' => 'Dead-endShuffle',
                                'enemy' => 'Vanilla',
@@ -457,6 +523,8 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],
@@ -481,6 +549,8 @@ class AosrPresetCommand {
                                'telestart' => 'false',
                                'mapassist' => 'false',
                                'doublechaos' => 'false',
+                               'reqallsouls' => 'false',
+                               'noww' => 'false',
                                'palette' => 'Vanilla',
                        ],
                ],