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