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