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