]> git.localhorst.tv Git - alttp.git/blobdiff - app/DiscordAppCommands/AosrPresetCommand.php
add aosr slash command
[alttp.git] / app / DiscordAppCommands / AosrPresetCommand.php
diff --git a/app/DiscordAppCommands/AosrPresetCommand.php b/app/DiscordAppCommands/AosrPresetCommand.php
new file mode 100644 (file)
index 0000000..8ec3eb4
--- /dev/null
@@ -0,0 +1,474 @@
+<?php
+
+namespace App\DiscordAppCommands;
+
+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 {
+
+       public static function create(Discord $discord) {
+               $choices = [];
+               foreach (static::$presets as $preset) {
+                       $choices[] = [
+                               'name' => $preset['name'],
+                               'value' => $preset['value'],
+                       ];
+               }
+               $cmd = $discord->application->commands->create([
+                       'name' => 'aosr',
+                       'type' => 1,
+                       'description' => '(testing) Generate an AoSRando seed.',
+                       'description_localizations' => [
+                               'de' => '(test) Generiert einen AoSRando Seed.',
+                       ],
+                       'options' => [[
+                               'name' => 'preset',
+                               'description' => '(testing) Generate an AoSRando seed from preset.',
+                               'description_localizations' => [
+                                       'de' => '(test) Generiert einen AoSRando Seed anhand eines Presets.',
+                               ],
+                               'type' => 1,
+                               'options' => [[
+                                       'name' => 'preset',
+                                       'description' => 'Which preset to use',
+                                       'description_localizations' => [
+                                               'de' => 'Welches Preset genutzt werden soll.',
+                                       ],
+                                       'type' => 3,
+                                       'required' => true,
+                                       'choices' => $choices,
+                               ]],
+                       ]],
+               ]);
+               $discord->application->commands->save($cmd);
+       }
+
+       public static function listen(Discord $discord) {
+               $discord->listenCommand(['aosr', 'preset'], function(Interaction $interaction) use ($discord) {
+                       $presetName = $interaction->data->options['preset']->options['preset']->value;
+                       $message = MessageBuilder::new();
+                       if (isset(static::$presets[$presetName])) {
+                               $preset = static::$presets[$presetName];
+                               $seed = strval(random_int(-2147483648, 2147483647));
+                               $params = array_merge(['seed' => $seed], $preset['settings']);
+                               $url = 'https://aosrando.surge.sh/?'.http_build_query($params, '', '&');
+                               $embed = new Embed($discord, [
+                                       'fields' => [
+                                               new Field($discord, [ 'name' => 'Preset', 'value' => $preset['name'], 'inline' => true ]),
+                                               new Field($discord, [ 'name' => 'Seed', 'value' => $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' => 'Link', 'value' => $url ]),
+                                       ],
+                                       'footer' => new Footer($discord, [
+                                               'text' => 'GrĂ¼n',
+                                       ]),
+                                       'timestamp' => now(),
+                                       'title' => 'AoSRando Seed',
+                                       'type' => 'rich',
+                                       'url' => $url,
+                               ]);
+                               $message->addEmbed($embed);
+                       } else {
+                               $message->setContent('unknown preset '.$presetName);
+                       }
+                       $interaction->respondWithMessage($message);
+                       return true;
+               });
+       }
+
+       private static $presets = [
+               'Normal' => [
+                       'name' => 'Normal',
+                       'value' => 'Normal',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'Vanilla',
+                               'boss' => 'Vanilla',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '2.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'false',
+                               'startshop' => 'Vanilla',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => 'Vanilla',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'Beginner' => [
+                       'name' => 'Beginner',
+                       'value' => 'Beginner',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'FirstAlways',
+                               'area' => 'Vanilla',
+                               'boss' => 'Vanilla',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '0',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'false',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => '2PerGroup',
+                               'levelexp' => 'Casual',
+                               'telestart' => 'false',
+                               'mapassist' => 'true',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'SpicyNormal' => [
+                       'name' => 'Spicy normal',
+                       'value' => 'SpicyNormal',
+                       'settings' => [
+                               'logic' => 'VeryRandom',
+                               'nodupes' => 'true',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'Vanilla',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'RandomPM20',
+                               'itempool' => 'Standard',
+                               'weight' => '1.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'true',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'RandHV',
+                               'shopSouls' => 'Half',
+                               'levelexp' => 'Hard',
+                               'telestart' => 'true',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'ExtraFastNormal' => [
+                       'name' => 'Extra fast normal',
+                       'value' => 'ExtraFastNormal',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'FirstAlways',
+                               'area' => 'Vanilla',
+                               'boss' => 'Vanilla',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '1.0',
+                               'grahm' => 'NoCheck',
+                               'kicker' => 'true',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'RandHV',
+                               'shopSouls' => 'Half',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'true',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'Area' => [
+                       'name' => 'Area',
+                       'value' => 'Area',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '2.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'false',
+                               'startshop' => 'Vanilla',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => 'Vanilla',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'AreaBeginner' =>       [
+                       'name' => 'Area beginner',
+                       'value' => 'AreaBeginner',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'FirstAlways',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '0',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'false',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => '2PerGroup',
+                               'levelexp' => 'Casual',
+                               'telestart' => 'false',
+                               'mapassist' => 'true',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'AreaSpicy' => [
+                       'name' => 'Area spicy',
+                       'value' => 'AreaSpicy',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'true',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'RandomPM20',
+                               'itempool' => 'Standard',
+                               'weight' => '1.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'true',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'RandHV',
+                               'shopSouls' => 'Half',
+                               'levelexp' => 'Hard',
+                               'telestart' => 'true',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'AreaAllBosses' => [
+                       'name' => 'Area all bosses',
+                       'value' => 'AreaAllBosses',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '2.5',
+                               'grahm' => 'AllBosses',
+                               'kicker' => 'true',
+                               'startshop' => 'Unlocked',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => '2PerGroup',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'AreaExtraFast' => [
+                       'name' => 'Area extra fast',
+                       'value' => 'AreaExtraFast',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'FirstAlways',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '1.0',
+                               'grahm' => 'NoCheck',
+                               'kicker' => 'true',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'RandHV',
+                               'shopSouls' => 'Half',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'true',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'AreaExpert' => [
+                       'name' => 'Area expert',
+                       'value' => 'AreaExpert',
+                       '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',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'DoorAllBossesEasy' => [
+                       'name' => 'Door all bosses easy',
+                       'value' => 'DoorAllBossesEasy',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'DoorRandom',
+                               'boss' => 'Vanilla',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '0',
+                               'grahm' => 'AllBosses',
+                               'kicker' => 'true',
+                               'startshop' => 'Unlocked',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => '2PerGroup',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'true',
+                               'mapassist' => 'true',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'DoorAllBosses' => [
+                       'name' => 'Door all bosses',
+                       'value' => 'DoorAllBosses',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'DoorRandom',
+                               'boss' => 'Vanilla',
+                               'enemy' => 'RandomPM20',
+                               'itempool' => 'Standard',
+                               'weight' => '0',
+                               'grahm' => 'AllBosses',
+                               'kicker' => 'true',
+                               'startshop' => 'Vanilla',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => '2PerGroup',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'SGLive2020' => [
+                       'name' => 'SGLive 2020',
+                       'value' => 'SGLive2020',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'Vanilla',
+                               'boss' => 'Vanilla',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '2.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'false',
+                               'startshop' => 'Vanilla',
+                               'shopprice' => 'Vanilla',
+                               'shopSouls' => 'Vanilla',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'SGLive2021' => [
+                       'name' => 'SGLive 2021',
+                       'value' => 'SGLive2021',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'FirstAlways',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '2.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'false',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'RandHV',
+                               'shopSouls' => 'Half',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'Tournament2021' => [
+                       'name' => 'Tournament 2021',
+                       'value' => 'Tournament2021',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'Rand70Dup',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '2.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'false',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'RandHV',
+                               'shopSouls' => 'Half',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+               'Tournament2022' => [
+                       'name' => 'Tournament 2022',
+                       'value' => 'Tournament2022',
+                       'settings' => [
+                               'logic' => 'AreaTechTiers',
+                               'nodupes' => 'false',
+                               'panther' => 'FirstAlways',
+                               'area' => 'AreaRandom',
+                               'boss' => 'Dead-endShuffle',
+                               'enemy' => 'Vanilla',
+                               'itempool' => 'Standard',
+                               'weight' => '2.5',
+                               'grahm' => 'BookSouls',
+                               'kicker' => 'false',
+                               'startshop' => 'Unlocked30k',
+                               'shopprice' => 'RandHV',
+                               'shopSouls' => 'Half',
+                               'levelexp' => 'Vanilla',
+                               'telestart' => 'false',
+                               'mapassist' => 'false',
+                               'doublechaos' => 'false',
+                               'palette' => 'Vanilla',
+                       ],
+               ],
+       ];
+
+}