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