]> git.localhorst.tv Git - alttp.git/blob - app/DiscordAppCommands/AosrPresetCommand.php
remove aosr command
[alttp.git] / app / DiscordAppCommands / AosrPresetCommand.php
1 <?php
2
3 namespace App\DiscordAppCommands;
4
5 use App\Models\AosSeed;
6 use Discord\Builders\MessageBuilder;
7 use Discord\Discord;
8 use Discord\Parts\Interactions\Interaction;
9
10 class AosrPresetCommand {
11
12         public static function create(Discord $discord) {
13                 $choices = [];
14                 foreach (static::$presets as $preset) {
15                         $choices[] = [
16                                 'name' => $preset['name'],
17                                 'value' => $preset['value'],
18                         ];
19                 }
20                 $cmd = $discord->application->commands->create([
21                         'name' => 'aosr',
22                         'type' => 1,
23                         'description' => 'Generate an AoSRando seed.',
24                         'description_localizations' => [
25                                 'de' => 'Generiert einen AoSRando Seed.',
26                         ],
27                         'options' => [[
28                                 'name' => 'preset',
29                                 'description' => 'Generate an AoSRando seed from preset.',
30                                 'description_localizations' => [
31                                         'de' => 'Generiert einen AoSRando Seed anhand eines Presets.',
32                                 ],
33                                 'type' => 1,
34                                 'options' => [[
35                                         'name' => 'preset',
36                                         'description' => 'Which preset to use',
37                                         'description_localizations' => [
38                                                 'de' => 'Welches Preset genutzt werden soll.',
39                                         ],
40                                         'type' => 3,
41                                         'required' => true,
42                                         'choices' => $choices,
43                                 ], [
44                                         'name' => 'race',
45                                         'description' => 'Generate race ROM, seed will be hidden',
46                                         'description_localizations' => [
47                                                 'de' => 'Race ROM generieren, Seed wird versteckt.',
48                                         ],
49                                         'type' => 5,
50                                         'required' => false,
51                                 ]],
52                         ]],
53                 ]);
54                 $discord->application->commands->save($cmd);
55         }
56
57         public static function delete(Discord $discord) {
58                 $discord->application->commands->freshen()->then(function () use ($discord) {
59                         $cmd = $discord->application->commands->find(function ($cmd) {
60                                 return $cmd->name == 'aosr';
61                         });
62                         if ($cmd) {
63                                 $discord->application->commands->delete($cmd);
64                         }
65                 });
66         }
67
68         public static function presetByName($name) {
69                 if (isset(static::$presets[$name])) {
70                         return static::$presets[$name];
71                 }
72                 foreach (static::$presets as $presetName => $preset) {
73                         if (strcasecmp($name, $presetName) === 0) {
74                                 return $preset;
75                         }
76                 }
77                 return null;
78         }
79
80         public static function listen(Discord $discord) {
81                 $discord->listenCommand(['aosr', 'preset'], function(Interaction $interaction) use ($discord) {
82                         $interaction
83                                 ->acknowledgeWithResponse()
84                                 ->done(function() use($discord, $interaction) {
85                                 $presetName = $interaction->data->options['preset']->options['preset']->value;
86                                 $race =  isset($interaction->data->options['preset']->options['race'])
87                                         ? $interaction->data->options['preset']->options['race']->value : false;
88                                 if (isset(static::$presets[$presetName])) {
89                                         $preset = static::$presets[$presetName];
90                                         $seed = AosSeed::generateSurge($presetName, $preset['settings'], $race);
91
92                                         $process = $seed->createProcess();
93                                         $process->on('exit', function() use ($discord, $interaction, $seed) {
94                                                 $seed = $seed->fresh();
95
96                                                 $embed = $seed->createEmbed($discord);
97                                                 $message = MessageBuilder::new();
98                                                 $message->addEmbed($embed);
99
100                                                 $interaction->updateOriginalResponse($message);
101                                         });
102
103                                         $process->start($discord->getLoop());
104                                 } else {
105                                         $message = MessageBuilder::new();
106                                         $message->setContent('unknown preset '.$presetName);
107                                         $interaction->updateOriginalResponse($message);
108                                 }
109                         });
110                         return true;
111                 });
112         }
113
114         public static $presets = [
115                 'Normal' => [
116                         'name' => 'Normal',
117                         'value' => 'Normal',
118                         'settings' => [
119                                 'logic' => 'AreaTechTiers',
120                                 'nodupes' => 'false',
121                                 'panther' => 'Rand70Dup',
122                                 'area' => 'Vanilla',
123                                 'boss' => 'Vanilla',
124                                 'enemy' => 'Vanilla',
125                                 'itempool' => 'Standard',
126                                 'weight' => '2.5',
127                                 'grahm' => 'BookSouls',
128                                 'kicker' => 'false',
129                                 'startshop' => 'Vanilla',
130                                 'shopprice' => 'Vanilla',
131                                 'shopSouls' => 'Vanilla',
132                                 'levelexp' => 'Vanilla',
133                                 'telestart' => 'false',
134                                 'mapassist' => 'false',
135                                 'doublechaos' => 'false',
136                                 'reqallsouls' => 'false',
137                                 'noww' => 'false',
138                                 'palette' => 'Vanilla',
139                         ],
140                 ],
141                 'Beginner' => [
142                         'name' => 'Beginner',
143                         'value' => 'Beginner',
144                         'settings' => [
145                                 'logic' => 'AreaTechTiers',
146                                 'nodupes' => 'false',
147                                 'panther' => 'FirstAlways',
148                                 'area' => 'Vanilla',
149                                 'boss' => 'Vanilla',
150                                 'enemy' => 'Vanilla',
151                                 'itempool' => 'Standard',
152                                 'weight' => '0',
153                                 'grahm' => 'BookSouls',
154                                 'kicker' => 'false',
155                                 'startshop' => 'Unlocked30k',
156                                 'shopprice' => 'Vanilla',
157                                 'shopSouls' => '2PerGroup',
158                                 'levelexp' => 'Casual',
159                                 'telestart' => 'false',
160                                 'mapassist' => 'true',
161                                 'doublechaos' => 'false',
162                                 'reqallsouls' => 'false',
163                                 'noww' => 'false',
164                                 'palette' => 'Vanilla',
165                         ],
166                 ],
167                 'SpicyNormal' => [
168                         'name' => 'Spicy normal',
169                         'value' => 'SpicyNormal',
170                         'settings' => [
171                                 'logic' => 'VeryRandom',
172                                 'nodupes' => 'true',
173                                 'panther' => 'Rand70Dup',
174                                 'area' => 'Vanilla',
175                                 'boss' => 'Dead-endShuffle',
176                                 'enemy' => 'RandomPM20',
177                                 'itempool' => 'Standard',
178                                 'weight' => '1.5',
179                                 'grahm' => 'BookSouls',
180                                 'kicker' => 'true',
181                                 'startshop' => 'Unlocked30k',
182                                 'shopprice' => 'RandHV',
183                                 'shopSouls' => 'Half',
184                                 'levelexp' => 'Hard',
185                                 'telestart' => 'true',
186                                 'mapassist' => 'false',
187                                 'doublechaos' => 'false',
188                                 'reqallsouls' => 'false',
189                                 'noww' => 'false',
190                                 'palette' => 'Vanilla',
191                         ],
192                 ],
193                 'ExtraFastNormal' => [
194                         'name' => 'Extra fast normal',
195                         'value' => 'ExtraFastNormal',
196                         'settings' => [
197                                 'logic' => 'AreaTechTiers',
198                                 'nodupes' => 'false',
199                                 'panther' => 'FirstAlways',
200                                 'area' => 'Vanilla',
201                                 'boss' => 'Vanilla',
202                                 'enemy' => 'Vanilla',
203                                 'itempool' => 'Standard',
204                                 'weight' => '1.0',
205                                 'grahm' => 'NoCheck',
206                                 'kicker' => 'true',
207                                 'startshop' => 'Unlocked30k',
208                                 'shopprice' => 'RandHV',
209                                 'shopSouls' => 'Half',
210                                 'levelexp' => 'Vanilla',
211                                 'telestart' => 'true',
212                                 'mapassist' => 'false',
213                                 'doublechaos' => 'false',
214                                 'reqallsouls' => 'false',
215                                 'noww' => 'false',
216                                 'palette' => 'Vanilla',
217                         ],
218                 ],
219                 'Area' => [
220                         'name' => 'Area',
221                         'value' => 'Area',
222                         'settings' => [
223                                 'logic' => 'AreaTechTiers',
224                                 'nodupes' => 'false',
225                                 'panther' => 'Rand70Dup',
226                                 'area' => 'AreaRandom',
227                                 'boss' => 'Dead-endShuffle',
228                                 'enemy' => 'Vanilla',
229                                 'itempool' => 'Standard',
230                                 'weight' => '2.5',
231                                 'grahm' => 'BookSouls',
232                                 'kicker' => 'false',
233                                 'startshop' => 'Vanilla',
234                                 'shopprice' => 'Vanilla',
235                                 'shopSouls' => 'Vanilla',
236                                 'levelexp' => 'Vanilla',
237                                 'telestart' => 'false',
238                                 'mapassist' => 'false',
239                                 'doublechaos' => 'false',
240                                 'reqallsouls' => 'false',
241                                 'noww' => 'false',
242                                 'palette' => 'Vanilla',
243                         ],
244                 ],
245                 'AreaBeginner' =>       [
246                         'name' => 'Area beginner',
247                         'value' => 'AreaBeginner',
248                         'settings' => [
249                                 'logic' => 'AreaTechTiers',
250                                 'nodupes' => 'false',
251                                 'panther' => 'FirstAlways',
252                                 'area' => 'AreaRandom',
253                                 'boss' => 'Dead-endShuffle',
254                                 'enemy' => 'Vanilla',
255                                 'itempool' => 'Standard',
256                                 'weight' => '0',
257                                 'grahm' => 'BookSouls',
258                                 'kicker' => 'false',
259                                 'startshop' => 'Unlocked30k',
260                                 'shopprice' => 'Vanilla',
261                                 'shopSouls' => '2PerGroup',
262                                 'levelexp' => 'Casual',
263                                 'telestart' => 'false',
264                                 'mapassist' => 'true',
265                                 'doublechaos' => 'false',
266                                 'reqallsouls' => 'false',
267                                 'noww' => 'false',
268                                 'palette' => 'Vanilla',
269                         ],
270                 ],
271                 'AreaSpicy' => [
272                         'name' => 'Area spicy',
273                         'value' => 'AreaSpicy',
274                         'settings' => [
275                                 'logic' => 'AreaTechTiers',
276                                 'nodupes' => 'true',
277                                 'panther' => 'Rand70Dup',
278                                 'area' => 'AreaRandom',
279                                 'boss' => 'Dead-endShuffle',
280                                 'enemy' => 'RandomPM20',
281                                 'itempool' => 'Standard',
282                                 'weight' => '1.5',
283                                 'grahm' => 'BookSouls',
284                                 'kicker' => 'true',
285                                 'startshop' => 'Unlocked30k',
286                                 'shopprice' => 'RandHV',
287                                 'shopSouls' => 'Half',
288                                 'levelexp' => 'Hard',
289                                 'telestart' => 'true',
290                                 'mapassist' => 'false',
291                                 'doublechaos' => 'false',
292                                 'reqallsouls' => 'false',
293                                 'noww' => 'false',
294                                 'palette' => 'Vanilla',
295                         ],
296                 ],
297                 'AreaAllBosses' => [
298                         'name' => 'Area all bosses',
299                         'value' => 'AreaAllBosses',
300                         'settings' => [
301                                 'logic' => 'AreaTechTiers',
302                                 'nodupes' => 'false',
303                                 'panther' => 'Rand70Dup',
304                                 'area' => 'AreaRandom',
305                                 'boss' => 'Dead-endShuffle',
306                                 'enemy' => 'Vanilla',
307                                 'itempool' => 'Standard',
308                                 'weight' => '2.5',
309                                 'grahm' => 'AllBosses',
310                                 'kicker' => 'true',
311                                 'startshop' => 'Unlocked',
312                                 'shopprice' => 'Vanilla',
313                                 'shopSouls' => '2PerGroup',
314                                 'levelexp' => 'Vanilla',
315                                 'telestart' => 'false',
316                                 'mapassist' => 'false',
317                                 'doublechaos' => 'false',
318                                 'reqallsouls' => 'false',
319                                 'noww' => 'false',
320                                 'palette' => 'Vanilla',
321                         ],
322                 ],
323                 'AreaExtraFast' => [
324                         'name' => 'Area extra fast',
325                         'value' => 'AreaExtraFast',
326                         'settings' => [
327                                 'logic' => 'AreaTechTiers',
328                                 'nodupes' => 'false',
329                                 'panther' => 'FirstAlways',
330                                 'area' => 'AreaRandom',
331                                 'boss' => 'Dead-endShuffle',
332                                 'enemy' => 'Vanilla',
333                                 'itempool' => 'Standard',
334                                 'weight' => '1.0',
335                                 'grahm' => 'NoCheck',
336                                 'kicker' => 'true',
337                                 'startshop' => 'Unlocked30k',
338                                 'shopprice' => 'RandHV',
339                                 'shopSouls' => 'Half',
340                                 'levelexp' => 'Vanilla',
341                                 'telestart' => 'true',
342                                 'mapassist' => 'false',
343                                 'doublechaos' => 'false',
344                                 'reqallsouls' => 'false',
345                                 'noww' => 'false',
346                                 'palette' => 'Vanilla',
347                         ],
348                 ],
349                 'AreaExpert' => [
350                         'name' => 'Area expert',
351                         'value' => 'AreaExpert',
352                         'settings' => [
353                                 'logic' => 'AreaTechTiers',
354                                 'nodupes' => 'true',
355                                 'panther' => 'NeverExists',
356                                 'area' => 'AreaRandom',
357                                 'boss' => 'Dead-endShuffle',
358                                 'enemy' => 'RandomNoLimit',
359                                 'itempool' => 'Standard',
360                                 'weight' => '2.5',
361                                 'grahm' => 'BookSouls',
362                                 'kicker' => 'true',
363                                 'startshop' => 'Vanilla',
364                                 'shopprice' => 'Vanilla',
365                                 'shopSouls' => 'Half',
366                                 'levelexp' => 'Lvl1',
367                                 'telestart' => 'false',
368                                 'mapassist' => 'false',
369                                 'doublechaos' => 'true',
370                                 'reqallsouls' => 'false',
371                                 'noww' => 'false',
372                                 'palette' => 'Vanilla',
373                         ],
374                 ],
375                 'AreaRequireAllSouls' => [
376                         'name' => 'Area require all souls',
377                         'value' => 'AreaRequireAllSouls',
378                         'settings' => [
379                                 'logic' => 'AreaTechTiers',
380                                 'nodupes' => 'true',
381                                 'panther' => 'NeverExists',
382                                 'area' => 'AreaRandom',
383                                 'boss' => 'Dead-endShuffle',
384                                 'enemy' => 'RandomNoLimit',
385                                 'itempool' => 'Standard',
386                                 'weight' => '2.5',
387                                 'grahm' => 'BookSouls',
388                                 'kicker' => 'true',
389                                 'startshop' => 'Vanilla',
390                                 'shopprice' => 'Vanilla',
391                                 'shopSouls' => 'Half',
392                                 'levelexp' => 'Lvl1',
393                                 'telestart' => 'false',
394                                 'mapassist' => 'false',
395                                 'doublechaos' => 'true',
396                                 'reqallsouls' => 'true',
397                                 'noww' => 'false',
398                                 'palette' => 'Vanilla',
399                         ],
400                 ],
401                 'DoorAllBossesEasy' => [
402                         'name' => 'Door all bosses easy',
403                         'value' => 'DoorAllBossesEasy',
404                         'settings' => [
405                                 'logic' => 'AreaTechTiers',
406                                 'nodupes' => 'false',
407                                 'panther' => 'Rand70Dup',
408                                 'area' => 'DoorRandom',
409                                 'boss' => 'Vanilla',
410                                 'enemy' => 'Vanilla',
411                                 'itempool' => 'Standard',
412                                 'weight' => '0',
413                                 'grahm' => 'AllBosses',
414                                 'kicker' => 'true',
415                                 'startshop' => 'Unlocked',
416                                 'shopprice' => 'Vanilla',
417                                 'shopSouls' => '2PerGroup',
418                                 'levelexp' => 'Vanilla',
419                                 'telestart' => 'true',
420                                 'mapassist' => 'true',
421                                 'doublechaos' => 'false',
422                                 'reqallsouls' => 'false',
423                                 'noww' => 'false',
424                                 'palette' => 'Vanilla',
425                         ],
426                 ],
427                 'DoorAllBosses' => [
428                         'name' => 'Door all bosses',
429                         'value' => 'DoorAllBosses',
430                         'settings' => [
431                                 'logic' => 'AreaTechTiers',
432                                 'nodupes' => 'false',
433                                 'panther' => 'Rand70Dup',
434                                 'area' => 'DoorRandom',
435                                 'boss' => 'Vanilla',
436                                 'enemy' => 'RandomPM20',
437                                 'itempool' => 'Standard',
438                                 'weight' => '0',
439                                 'grahm' => 'AllBosses',
440                                 'kicker' => 'true',
441                                 'startshop' => 'Vanilla',
442                                 'shopprice' => 'Vanilla',
443                                 'shopSouls' => '2PerGroup',
444                                 'levelexp' => 'Vanilla',
445                                 'telestart' => 'false',
446                                 'mapassist' => 'false',
447                                 'doublechaos' => 'false',
448                                 'reqallsouls' => 'false',
449                                 'noww' => 'false',
450                                 'palette' => 'Vanilla',
451                         ],
452                 ],
453                 'SGLive2020' => [
454                         'name' => 'SGLive 2020',
455                         'value' => 'SGLive2020',
456                         'settings' => [
457                                 'logic' => 'AreaTechTiers',
458                                 'nodupes' => 'false',
459                                 'panther' => 'Rand70Dup',
460                                 'area' => 'Vanilla',
461                                 'boss' => 'Vanilla',
462                                 'enemy' => 'Vanilla',
463                                 'itempool' => 'Standard',
464                                 'weight' => '2.5',
465                                 'grahm' => 'BookSouls',
466                                 'kicker' => 'false',
467                                 'startshop' => 'Vanilla',
468                                 'shopprice' => 'Vanilla',
469                                 'shopSouls' => 'Vanilla',
470                                 'levelexp' => 'Vanilla',
471                                 'telestart' => 'false',
472                                 'mapassist' => 'false',
473                                 'doublechaos' => 'false',
474                                 'reqallsouls' => 'false',
475                                 'noww' => 'false',
476                                 'palette' => 'Vanilla',
477                         ],
478                 ],
479                 'Tournament2021' => [
480                         'name' => 'Tournament 2021',
481                         'value' => 'Tournament2021',
482                         'settings' => [
483                                 'logic' => 'AreaTechTiers',
484                                 'nodupes' => 'false',
485                                 'panther' => 'Rand70Dup',
486                                 'area' => 'AreaRandom',
487                                 'boss' => 'Dead-endShuffle',
488                                 'enemy' => 'Vanilla',
489                                 'itempool' => 'Standard',
490                                 'weight' => '2.5',
491                                 'grahm' => 'BookSouls',
492                                 'kicker' => 'false',
493                                 'startshop' => 'Unlocked30k',
494                                 'shopprice' => 'RandHV',
495                                 'shopSouls' => 'Half',
496                                 'levelexp' => 'Vanilla',
497                                 'telestart' => 'false',
498                                 'mapassist' => 'false',
499                                 'doublechaos' => 'false',
500                                 'reqallsouls' => 'false',
501                                 'noww' => 'false',
502                                 'palette' => 'Vanilla',
503                         ],
504                 ],
505                 'SGLive2021' => [
506                         'name' => 'SGLive 2021',
507                         'value' => 'SGLive2021',
508                         'settings' => [
509                                 'logic' => 'AreaTechTiers',
510                                 'nodupes' => 'false',
511                                 'panther' => 'FirstAlways',
512                                 'area' => 'AreaRandom',
513                                 'boss' => 'Dead-endShuffle',
514                                 'enemy' => 'Vanilla',
515                                 'itempool' => 'Standard',
516                                 'weight' => '2.5',
517                                 'grahm' => 'BookSouls',
518                                 'kicker' => 'false',
519                                 'startshop' => 'Unlocked30k',
520                                 'shopprice' => 'RandHV',
521                                 'shopSouls' => 'Half',
522                                 'levelexp' => 'Vanilla',
523                                 'telestart' => 'false',
524                                 'mapassist' => 'false',
525                                 'doublechaos' => 'false',
526                                 'reqallsouls' => 'false',
527                                 'noww' => 'false',
528                                 'palette' => 'Vanilla',
529                         ],
530                 ],
531                 'Tournament2022' => [
532                         'name' => 'Tournament 2022',
533                         'value' => 'Tournament2022',
534                         'settings' => [
535                                 'logic' => 'AreaTechTiers',
536                                 'nodupes' => 'false',
537                                 'panther' => 'FirstAlways',
538                                 'area' => 'AreaRandom',
539                                 'boss' => 'Dead-endShuffle',
540                                 'enemy' => 'Vanilla',
541                                 'itempool' => 'Standard',
542                                 'weight' => '2.5',
543                                 'grahm' => 'BookSouls',
544                                 'kicker' => 'false',
545                                 'startshop' => 'Unlocked30k',
546                                 'shopprice' => 'RandHV',
547                                 'shopSouls' => 'Half',
548                                 'levelexp' => 'Vanilla',
549                                 'telestart' => 'false',
550                                 'mapassist' => 'false',
551                                 'doublechaos' => 'false',
552                                 'reqallsouls' => 'false',
553                                 'noww' => 'false',
554                                 'palette' => 'Vanilla',
555                         ],
556                 ],
557         ];
558
559 }