]> git.localhorst.tv Git - alttp.git/blob - app/DiscordAppCommands/AosrPresetCommand.php
9a537db8006452ed349a99cc7a1fec099746d856
[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                                 'palette' => 'Vanilla',
114                         ],
115                 ],
116                 'Beginner' => [
117                         'name' => 'Beginner',
118                         'value' => 'Beginner',
119                         'settings' => [
120                                 'logic' => 'AreaTechTiers',
121                                 'nodupes' => 'false',
122                                 'panther' => 'FirstAlways',
123                                 'area' => 'Vanilla',
124                                 'boss' => 'Vanilla',
125                                 'enemy' => 'Vanilla',
126                                 'itempool' => 'Standard',
127                                 'weight' => '0',
128                                 'grahm' => 'BookSouls',
129                                 'kicker' => 'false',
130                                 'startshop' => 'Unlocked30k',
131                                 'shopprice' => 'Vanilla',
132                                 'shopSouls' => '2PerGroup',
133                                 'levelexp' => 'Casual',
134                                 'telestart' => 'false',
135                                 'mapassist' => 'true',
136                                 'doublechaos' => 'false',
137                                 'palette' => 'Vanilla',
138                         ],
139                 ],
140                 'SpicyNormal' => [
141                         'name' => 'Spicy normal',
142                         'value' => 'SpicyNormal',
143                         'settings' => [
144                                 'logic' => 'VeryRandom',
145                                 'nodupes' => 'true',
146                                 'panther' => 'Rand70Dup',
147                                 'area' => 'Vanilla',
148                                 'boss' => 'Dead-endShuffle',
149                                 'enemy' => 'RandomPM20',
150                                 'itempool' => 'Standard',
151                                 'weight' => '1.5',
152                                 'grahm' => 'BookSouls',
153                                 'kicker' => 'true',
154                                 'startshop' => 'Unlocked30k',
155                                 'shopprice' => 'RandHV',
156                                 'shopSouls' => 'Half',
157                                 'levelexp' => 'Hard',
158                                 'telestart' => 'true',
159                                 'mapassist' => 'false',
160                                 'doublechaos' => 'false',
161                                 'palette' => 'Vanilla',
162                         ],
163                 ],
164                 'ExtraFastNormal' => [
165                         'name' => 'Extra fast normal',
166                         'value' => 'ExtraFastNormal',
167                         'settings' => [
168                                 'logic' => 'AreaTechTiers',
169                                 'nodupes' => 'false',
170                                 'panther' => 'FirstAlways',
171                                 'area' => 'Vanilla',
172                                 'boss' => 'Vanilla',
173                                 'enemy' => 'Vanilla',
174                                 'itempool' => 'Standard',
175                                 'weight' => '1.0',
176                                 'grahm' => 'NoCheck',
177                                 'kicker' => 'true',
178                                 'startshop' => 'Unlocked30k',
179                                 'shopprice' => 'RandHV',
180                                 'shopSouls' => 'Half',
181                                 'levelexp' => 'Vanilla',
182                                 'telestart' => 'true',
183                                 'mapassist' => 'false',
184                                 'doublechaos' => 'false',
185                                 'palette' => 'Vanilla',
186                         ],
187                 ],
188                 'Area' => [
189                         'name' => 'Area',
190                         'value' => 'Area',
191                         'settings' => [
192                                 'logic' => 'AreaTechTiers',
193                                 'nodupes' => 'false',
194                                 'panther' => 'Rand70Dup',
195                                 'area' => 'AreaRandom',
196                                 'boss' => 'Dead-endShuffle',
197                                 'enemy' => 'Vanilla',
198                                 'itempool' => 'Standard',
199                                 'weight' => '2.5',
200                                 'grahm' => 'BookSouls',
201                                 'kicker' => 'false',
202                                 'startshop' => 'Vanilla',
203                                 'shopprice' => 'Vanilla',
204                                 'shopSouls' => 'Vanilla',
205                                 'levelexp' => 'Vanilla',
206                                 'telestart' => 'false',
207                                 'mapassist' => 'false',
208                                 'doublechaos' => 'false',
209                                 'palette' => 'Vanilla',
210                         ],
211                 ],
212                 'AreaBeginner' =>       [
213                         'name' => 'Area beginner',
214                         'value' => 'AreaBeginner',
215                         'settings' => [
216                                 'logic' => 'AreaTechTiers',
217                                 'nodupes' => 'false',
218                                 'panther' => 'FirstAlways',
219                                 'area' => 'AreaRandom',
220                                 'boss' => 'Dead-endShuffle',
221                                 'enemy' => 'Vanilla',
222                                 'itempool' => 'Standard',
223                                 'weight' => '0',
224                                 'grahm' => 'BookSouls',
225                                 'kicker' => 'false',
226                                 'startshop' => 'Unlocked30k',
227                                 'shopprice' => 'Vanilla',
228                                 'shopSouls' => '2PerGroup',
229                                 'levelexp' => 'Casual',
230                                 'telestart' => 'false',
231                                 'mapassist' => 'true',
232                                 'doublechaos' => 'false',
233                                 'palette' => 'Vanilla',
234                         ],
235                 ],
236                 'AreaSpicy' => [
237                         'name' => 'Area spicy',
238                         'value' => 'AreaSpicy',
239                         'settings' => [
240                                 'logic' => 'AreaTechTiers',
241                                 'nodupes' => 'true',
242                                 'panther' => 'Rand70Dup',
243                                 'area' => 'AreaRandom',
244                                 'boss' => 'Dead-endShuffle',
245                                 'enemy' => 'RandomPM20',
246                                 'itempool' => 'Standard',
247                                 'weight' => '1.5',
248                                 'grahm' => 'BookSouls',
249                                 'kicker' => 'true',
250                                 'startshop' => 'Unlocked30k',
251                                 'shopprice' => 'RandHV',
252                                 'shopSouls' => 'Half',
253                                 'levelexp' => 'Hard',
254                                 'telestart' => 'true',
255                                 'mapassist' => 'false',
256                                 'doublechaos' => 'false',
257                                 'palette' => 'Vanilla',
258                         ],
259                 ],
260                 'AreaAllBosses' => [
261                         'name' => 'Area all bosses',
262                         'value' => 'AreaAllBosses',
263                         'settings' => [
264                                 'logic' => 'AreaTechTiers',
265                                 'nodupes' => 'false',
266                                 'panther' => 'Rand70Dup',
267                                 'area' => 'AreaRandom',
268                                 'boss' => 'Dead-endShuffle',
269                                 'enemy' => 'Vanilla',
270                                 'itempool' => 'Standard',
271                                 'weight' => '2.5',
272                                 'grahm' => 'AllBosses',
273                                 'kicker' => 'true',
274                                 'startshop' => 'Unlocked',
275                                 'shopprice' => 'Vanilla',
276                                 'shopSouls' => '2PerGroup',
277                                 'levelexp' => 'Vanilla',
278                                 'telestart' => 'false',
279                                 'mapassist' => 'false',
280                                 'doublechaos' => 'false',
281                                 'palette' => 'Vanilla',
282                         ],
283                 ],
284                 'AreaExtraFast' => [
285                         'name' => 'Area extra fast',
286                         'value' => 'AreaExtraFast',
287                         'settings' => [
288                                 'logic' => 'AreaTechTiers',
289                                 'nodupes' => 'false',
290                                 'panther' => 'FirstAlways',
291                                 'area' => 'AreaRandom',
292                                 'boss' => 'Dead-endShuffle',
293                                 'enemy' => 'Vanilla',
294                                 'itempool' => 'Standard',
295                                 'weight' => '1.0',
296                                 'grahm' => 'NoCheck',
297                                 'kicker' => 'true',
298                                 'startshop' => 'Unlocked30k',
299                                 'shopprice' => 'RandHV',
300                                 'shopSouls' => 'Half',
301                                 'levelexp' => 'Vanilla',
302                                 'telestart' => 'true',
303                                 'mapassist' => 'false',
304                                 'doublechaos' => 'false',
305                                 'palette' => 'Vanilla',
306                         ],
307                 ],
308                 'AreaExpert' => [
309                         'name' => 'Area expert',
310                         'value' => 'AreaExpert',
311                         'settings' => [
312                                 'logic' => 'AreaTechTiers',
313                                 'nodupes' => 'true',
314                                 'panther' => 'NeverExists',
315                                 'area' => 'AreaRandom',
316                                 'boss' => 'Dead-endShuffle',
317                                 'enemy' => 'RandomNoLimit',
318                                 'itempool' => 'Standard',
319                                 'weight' => '2.5',
320                                 'grahm' => 'BookSouls',
321                                 'kicker' => 'true',
322                                 'startshop' => 'Vanilla',
323                                 'shopprice' => 'Vanilla',
324                                 'shopSouls' => 'Half',
325                                 'levelexp' => 'Lvl1',
326                                 'telestart' => 'false',
327                                 'mapassist' => 'false',
328                                 'doublechaos' => 'true',
329                                 'palette' => 'Vanilla',
330                         ],
331                 ],
332                 'DoorAllBossesEasy' => [
333                         'name' => 'Door all bosses easy',
334                         'value' => 'DoorAllBossesEasy',
335                         'settings' => [
336                                 'logic' => 'AreaTechTiers',
337                                 'nodupes' => 'false',
338                                 'panther' => 'Rand70Dup',
339                                 'area' => 'DoorRandom',
340                                 'boss' => 'Vanilla',
341                                 'enemy' => 'Vanilla',
342                                 'itempool' => 'Standard',
343                                 'weight' => '0',
344                                 'grahm' => 'AllBosses',
345                                 'kicker' => 'true',
346                                 'startshop' => 'Unlocked',
347                                 'shopprice' => 'Vanilla',
348                                 'shopSouls' => '2PerGroup',
349                                 'levelexp' => 'Vanilla',
350                                 'telestart' => 'true',
351                                 'mapassist' => 'true',
352                                 'doublechaos' => 'false',
353                                 'palette' => 'Vanilla',
354                         ],
355                 ],
356                 'DoorAllBosses' => [
357                         'name' => 'Door all bosses',
358                         'value' => 'DoorAllBosses',
359                         'settings' => [
360                                 'logic' => 'AreaTechTiers',
361                                 'nodupes' => 'false',
362                                 'panther' => 'Rand70Dup',
363                                 'area' => 'DoorRandom',
364                                 'boss' => 'Vanilla',
365                                 'enemy' => 'RandomPM20',
366                                 'itempool' => 'Standard',
367                                 'weight' => '0',
368                                 'grahm' => 'AllBosses',
369                                 'kicker' => 'true',
370                                 'startshop' => 'Vanilla',
371                                 'shopprice' => 'Vanilla',
372                                 'shopSouls' => '2PerGroup',
373                                 'levelexp' => 'Vanilla',
374                                 'telestart' => 'false',
375                                 'mapassist' => 'false',
376                                 'doublechaos' => 'false',
377                                 'palette' => 'Vanilla',
378                         ],
379                 ],
380                 'SGLive2020' => [
381                         'name' => 'SGLive 2020',
382                         'value' => 'SGLive2020',
383                         'settings' => [
384                                 'logic' => 'AreaTechTiers',
385                                 'nodupes' => 'false',
386                                 'panther' => 'Rand70Dup',
387                                 'area' => 'Vanilla',
388                                 'boss' => 'Vanilla',
389                                 'enemy' => 'Vanilla',
390                                 'itempool' => 'Standard',
391                                 'weight' => '2.5',
392                                 'grahm' => 'BookSouls',
393                                 'kicker' => 'false',
394                                 'startshop' => 'Vanilla',
395                                 'shopprice' => 'Vanilla',
396                                 'shopSouls' => 'Vanilla',
397                                 'levelexp' => 'Vanilla',
398                                 'telestart' => 'false',
399                                 'mapassist' => 'false',
400                                 'doublechaos' => 'false',
401                                 'palette' => 'Vanilla',
402                         ],
403                 ],
404                 'SGLive2021' => [
405                         'name' => 'SGLive 2021',
406                         'value' => 'SGLive2021',
407                         'settings' => [
408                                 'logic' => 'AreaTechTiers',
409                                 'nodupes' => 'false',
410                                 'panther' => 'FirstAlways',
411                                 'area' => 'AreaRandom',
412                                 'boss' => 'Dead-endShuffle',
413                                 'enemy' => 'Vanilla',
414                                 'itempool' => 'Standard',
415                                 'weight' => '2.5',
416                                 'grahm' => 'BookSouls',
417                                 'kicker' => 'false',
418                                 'startshop' => 'Unlocked30k',
419                                 'shopprice' => 'RandHV',
420                                 'shopSouls' => 'Half',
421                                 'levelexp' => 'Vanilla',
422                                 'telestart' => 'false',
423                                 'mapassist' => 'false',
424                                 'doublechaos' => 'false',
425                                 'palette' => 'Vanilla',
426                         ],
427                 ],
428                 'Tournament2021' => [
429                         'name' => 'Tournament 2021',
430                         'value' => 'Tournament2021',
431                         'settings' => [
432                                 'logic' => 'AreaTechTiers',
433                                 'nodupes' => 'false',
434                                 'panther' => 'Rand70Dup',
435                                 'area' => 'AreaRandom',
436                                 'boss' => 'Dead-endShuffle',
437                                 'enemy' => 'Vanilla',
438                                 'itempool' => 'Standard',
439                                 'weight' => '2.5',
440                                 'grahm' => 'BookSouls',
441                                 'kicker' => 'false',
442                                 'startshop' => 'Unlocked30k',
443                                 'shopprice' => 'RandHV',
444                                 'shopSouls' => 'Half',
445                                 'levelexp' => 'Vanilla',
446                                 'telestart' => 'false',
447                                 'mapassist' => 'false',
448                                 'doublechaos' => 'false',
449                                 'palette' => 'Vanilla',
450                         ],
451                 ],
452                 'Tournament2022' => [
453                         'name' => 'Tournament 2022',
454                         'value' => 'Tournament2022',
455                         'settings' => [
456                                 'logic' => 'AreaTechTiers',
457                                 'nodupes' => 'false',
458                                 'panther' => 'FirstAlways',
459                                 'area' => 'AreaRandom',
460                                 'boss' => 'Dead-endShuffle',
461                                 'enemy' => 'Vanilla',
462                                 'itempool' => 'Standard',
463                                 'weight' => '2.5',
464                                 'grahm' => 'BookSouls',
465                                 'kicker' => 'false',
466                                 'startshop' => 'Unlocked30k',
467                                 'shopprice' => 'RandHV',
468                                 'shopSouls' => 'Half',
469                                 'levelexp' => 'Vanilla',
470                                 'telestart' => 'false',
471                                 'mapassist' => 'false',
472                                 'doublechaos' => 'false',
473                                 'palette' => 'Vanilla',
474                         ],
475                 ],
476         ];
477
478 }