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