3 namespace App\DiscordAppCommands;
5 use App\Models\AosSeed;
6 use Discord\Builders\MessageBuilder;
8 use Discord\Parts\Interactions\Interaction;
10 class AosrPresetCommand {
12 public static function create(Discord $discord) {
14 foreach (static::$presets as $preset) {
16 'name' => $preset['name'],
17 'value' => $preset['value'],
20 $cmd = $discord->application->commands->create([
23 'description' => 'Generate an AoSRando seed.',
24 'description_localizations' => [
25 'de' => 'Generiert einen AoSRando Seed.',
29 'description' => 'Generate an AoSRando seed from preset.',
30 'description_localizations' => [
31 'de' => 'Generiert einen AoSRando Seed anhand eines Presets.',
36 'description' => 'Which preset to use',
37 'description_localizations' => [
38 'de' => 'Welches Preset genutzt werden soll.',
42 'choices' => $choices,
45 'description' => 'Generate race ROM, seed will be hidden',
46 'description_localizations' => [
47 'de' => 'Race ROM generieren, Seed wird versteckt.',
54 $discord->application->commands->save($cmd);
57 public static function delete(Discord $discord) {
58 $discord->application->commands->freshen()->then(function () use ($discord) {
59 $cmd = $discord->application->commands->find(function ($cmd) {
60 return $cmd->name == 'aosr';
63 $discord->application->commands->delete($cmd);
68 public static function presetByName($name) {
69 if (isset(static::$presets[$name])) {
70 return static::$presets[$name];
72 foreach (static::$presets as $presetName => $preset) {
73 if (strcasecmp($name, $presetName) === 0) {
80 public static function listen(Discord $discord) {
81 $discord->listenCommand(['aosr', 'preset'], function(Interaction $interaction) use ($discord) {
83 ->acknowledgeWithResponse()
84 ->done(function() use($discord, $interaction) {
85 $presetName = $interaction->data->options['preset']->options['preset']->value;
86 $race = isset($interaction->data->options['preset']->options['race'])
87 ? $interaction->data->options['preset']->options['race']->value : false;
88 if (isset(static::$presets[$presetName])) {
89 $preset = static::$presets[$presetName];
90 $seed = AosSeed::generateSurge($presetName, $preset['settings'], $race);
92 $process = $seed->createProcess();
93 $process->on('exit', function() use ($discord, $interaction, $seed) {
94 $seed = $seed->fresh();
96 $embed = $seed->createEmbed($discord);
97 $message = MessageBuilder::new();
98 $message->addEmbed($embed);
100 $interaction->updateOriginalResponse($message);
103 $process->start($discord->getLoop());
105 $message = MessageBuilder::new();
106 $message->setContent('unknown preset '.$presetName);
107 $interaction->updateOriginalResponse($message);
114 public static $presets = [
119 'logic' => 'AreaTechTiers',
120 'nodupes' => 'false',
121 'panther' => 'Rand70Dup',
124 'enemy' => 'Vanilla',
125 'itempool' => 'Standard',
127 'grahm' => 'BookSouls',
129 'startshop' => 'Vanilla',
130 'shopprice' => 'Vanilla',
131 'shopSouls' => 'Vanilla',
132 'levelexp' => 'Vanilla',
133 'telestart' => 'false',
134 'mapassist' => 'false',
135 'doublechaos' => 'false',
136 'reqallsouls' => 'false',
138 'palette' => 'Vanilla',
142 'name' => 'Beginner',
143 'value' => 'Beginner',
145 'logic' => 'AreaTechTiers',
146 'nodupes' => 'false',
147 'panther' => 'FirstAlways',
150 'enemy' => 'Vanilla',
151 'itempool' => 'Standard',
153 'grahm' => 'BookSouls',
155 'startshop' => 'Unlocked30k',
156 'shopprice' => 'Vanilla',
157 'shopSouls' => '2PerGroup',
158 'levelexp' => 'Casual',
159 'telestart' => 'false',
160 'mapassist' => 'true',
161 'doublechaos' => 'false',
162 'reqallsouls' => 'false',
164 'palette' => 'Vanilla',
168 'name' => 'Spicy normal',
169 'value' => 'SpicyNormal',
171 'logic' => 'VeryRandom',
173 'panther' => 'Rand70Dup',
175 'boss' => 'Dead-endShuffle',
176 'enemy' => 'RandomPM20',
177 'itempool' => 'Standard',
179 'grahm' => 'BookSouls',
181 'startshop' => 'Unlocked30k',
182 'shopprice' => 'RandHV',
183 'shopSouls' => 'Half',
184 'levelexp' => 'Hard',
185 'telestart' => 'true',
186 'mapassist' => 'false',
187 'doublechaos' => 'false',
188 'reqallsouls' => 'false',
190 'palette' => 'Vanilla',
193 'ExtraFastNormal' => [
194 'name' => 'Extra fast normal',
195 'value' => 'ExtraFastNormal',
197 'logic' => 'AreaTechTiers',
198 'nodupes' => 'false',
199 'panther' => 'FirstAlways',
202 'enemy' => 'Vanilla',
203 'itempool' => 'Standard',
205 'grahm' => 'NoCheck',
207 'startshop' => 'Unlocked30k',
208 'shopprice' => 'RandHV',
209 'shopSouls' => 'Half',
210 'levelexp' => 'Vanilla',
211 'telestart' => 'true',
212 'mapassist' => 'false',
213 'doublechaos' => 'false',
214 'reqallsouls' => 'false',
216 'palette' => 'Vanilla',
223 'logic' => 'AreaTechTiers',
224 'nodupes' => 'false',
225 'panther' => 'Rand70Dup',
226 'area' => 'AreaRandom',
227 'boss' => 'Dead-endShuffle',
228 'enemy' => 'Vanilla',
229 'itempool' => 'Standard',
231 'grahm' => 'BookSouls',
233 'startshop' => 'Vanilla',
234 'shopprice' => 'Vanilla',
235 'shopSouls' => 'Vanilla',
236 'levelexp' => 'Vanilla',
237 'telestart' => 'false',
238 'mapassist' => 'false',
239 'doublechaos' => 'false',
240 'reqallsouls' => 'false',
242 'palette' => 'Vanilla',
246 'name' => 'Area beginner',
247 'value' => 'AreaBeginner',
249 'logic' => 'AreaTechTiers',
250 'nodupes' => 'false',
251 'panther' => 'FirstAlways',
252 'area' => 'AreaRandom',
253 'boss' => 'Dead-endShuffle',
254 'enemy' => 'Vanilla',
255 'itempool' => 'Standard',
257 'grahm' => 'BookSouls',
259 'startshop' => 'Unlocked30k',
260 'shopprice' => 'Vanilla',
261 'shopSouls' => '2PerGroup',
262 'levelexp' => 'Casual',
263 'telestart' => 'false',
264 'mapassist' => 'true',
265 'doublechaos' => 'false',
266 'reqallsouls' => 'false',
268 'palette' => 'Vanilla',
272 'name' => 'Area spicy',
273 'value' => 'AreaSpicy',
275 'logic' => 'AreaTechTiers',
277 'panther' => 'Rand70Dup',
278 'area' => 'AreaRandom',
279 'boss' => 'Dead-endShuffle',
280 'enemy' => 'RandomPM20',
281 'itempool' => 'Standard',
283 'grahm' => 'BookSouls',
285 'startshop' => 'Unlocked30k',
286 'shopprice' => 'RandHV',
287 'shopSouls' => 'Half',
288 'levelexp' => 'Hard',
289 'telestart' => 'true',
290 'mapassist' => 'false',
291 'doublechaos' => 'false',
292 'reqallsouls' => 'false',
294 'palette' => 'Vanilla',
298 'name' => 'Area all bosses',
299 'value' => 'AreaAllBosses',
301 'logic' => 'AreaTechTiers',
302 'nodupes' => 'false',
303 'panther' => 'Rand70Dup',
304 'area' => 'AreaRandom',
305 'boss' => 'Dead-endShuffle',
306 'enemy' => 'Vanilla',
307 'itempool' => 'Standard',
309 'grahm' => 'AllBosses',
311 'startshop' => 'Unlocked',
312 'shopprice' => 'Vanilla',
313 'shopSouls' => '2PerGroup',
314 'levelexp' => 'Vanilla',
315 'telestart' => 'false',
316 'mapassist' => 'false',
317 'doublechaos' => 'false',
318 'reqallsouls' => 'false',
320 'palette' => 'Vanilla',
324 'name' => 'Area extra fast',
325 'value' => 'AreaExtraFast',
327 'logic' => 'AreaTechTiers',
328 'nodupes' => 'false',
329 'panther' => 'FirstAlways',
330 'area' => 'AreaRandom',
331 'boss' => 'Dead-endShuffle',
332 'enemy' => 'Vanilla',
333 'itempool' => 'Standard',
335 'grahm' => 'NoCheck',
337 'startshop' => 'Unlocked30k',
338 'shopprice' => 'RandHV',
339 'shopSouls' => 'Half',
340 'levelexp' => 'Vanilla',
341 'telestart' => 'true',
342 'mapassist' => 'false',
343 'doublechaos' => 'false',
344 'reqallsouls' => 'false',
346 'palette' => 'Vanilla',
350 'name' => 'Area expert',
351 'value' => 'AreaExpert',
353 'logic' => 'AreaTechTiers',
355 'panther' => 'NeverExists',
356 'area' => 'AreaRandom',
357 'boss' => 'Dead-endShuffle',
358 'enemy' => 'RandomNoLimit',
359 'itempool' => 'Standard',
361 'grahm' => 'BookSouls',
363 'startshop' => 'Vanilla',
364 'shopprice' => 'Vanilla',
365 'shopSouls' => 'Half',
366 'levelexp' => 'Lvl1',
367 'telestart' => 'false',
368 'mapassist' => 'false',
369 'doublechaos' => 'true',
370 'reqallsouls' => 'false',
372 'palette' => 'Vanilla',
375 'AreaRequireAllSouls' => [
376 'name' => 'Area require all souls',
377 'value' => 'AreaRequireAllSouls',
379 'logic' => 'AreaTechTiers',
381 'panther' => 'NeverExists',
382 'area' => 'AreaRandom',
383 'boss' => 'Dead-endShuffle',
384 'enemy' => 'RandomNoLimit',
385 'itempool' => 'Standard',
387 'grahm' => 'BookSouls',
389 'startshop' => 'Vanilla',
390 'shopprice' => 'Vanilla',
391 'shopSouls' => 'Half',
392 'levelexp' => 'Lvl1',
393 'telestart' => 'false',
394 'mapassist' => 'false',
395 'doublechaos' => 'true',
396 'reqallsouls' => 'true',
398 'palette' => 'Vanilla',
401 'DoorAllBossesEasy' => [
402 'name' => 'Door all bosses easy',
403 'value' => 'DoorAllBossesEasy',
405 'logic' => 'AreaTechTiers',
406 'nodupes' => 'false',
407 'panther' => 'Rand70Dup',
408 'area' => 'DoorRandom',
410 'enemy' => 'Vanilla',
411 'itempool' => 'Standard',
413 'grahm' => 'AllBosses',
415 'startshop' => 'Unlocked',
416 'shopprice' => 'Vanilla',
417 'shopSouls' => '2PerGroup',
418 'levelexp' => 'Vanilla',
419 'telestart' => 'true',
420 'mapassist' => 'true',
421 'doublechaos' => 'false',
422 'reqallsouls' => 'false',
424 'palette' => 'Vanilla',
428 'name' => 'Door all bosses',
429 'value' => 'DoorAllBosses',
431 'logic' => 'AreaTechTiers',
432 'nodupes' => 'false',
433 'panther' => 'Rand70Dup',
434 'area' => 'DoorRandom',
436 'enemy' => 'RandomPM20',
437 'itempool' => 'Standard',
439 'grahm' => 'AllBosses',
441 'startshop' => 'Vanilla',
442 'shopprice' => 'Vanilla',
443 'shopSouls' => '2PerGroup',
444 'levelexp' => 'Vanilla',
445 'telestart' => 'false',
446 'mapassist' => 'false',
447 'doublechaos' => 'false',
448 'reqallsouls' => 'false',
450 'palette' => 'Vanilla',
454 'name' => 'SGLive 2020',
455 'value' => 'SGLive2020',
457 'logic' => 'AreaTechTiers',
458 'nodupes' => 'false',
459 'panther' => 'Rand70Dup',
462 'enemy' => 'Vanilla',
463 'itempool' => 'Standard',
465 'grahm' => 'BookSouls',
467 'startshop' => 'Vanilla',
468 'shopprice' => 'Vanilla',
469 'shopSouls' => 'Vanilla',
470 'levelexp' => 'Vanilla',
471 'telestart' => 'false',
472 'mapassist' => 'false',
473 'doublechaos' => 'false',
474 'reqallsouls' => 'false',
476 'palette' => 'Vanilla',
479 'Tournament2021' => [
480 'name' => 'Tournament 2021',
481 'value' => 'Tournament2021',
483 'logic' => 'AreaTechTiers',
484 'nodupes' => 'false',
485 'panther' => 'Rand70Dup',
486 'area' => 'AreaRandom',
487 'boss' => 'Dead-endShuffle',
488 'enemy' => 'Vanilla',
489 'itempool' => 'Standard',
491 'grahm' => 'BookSouls',
493 'startshop' => 'Unlocked30k',
494 'shopprice' => 'RandHV',
495 'shopSouls' => 'Half',
496 'levelexp' => 'Vanilla',
497 'telestart' => 'false',
498 'mapassist' => 'false',
499 'doublechaos' => 'false',
500 'reqallsouls' => 'false',
502 'palette' => 'Vanilla',
506 'name' => 'SGLive 2021',
507 'value' => 'SGLive2021',
509 'logic' => 'AreaTechTiers',
510 'nodupes' => 'false',
511 'panther' => 'FirstAlways',
512 'area' => 'AreaRandom',
513 'boss' => 'Dead-endShuffle',
514 'enemy' => 'Vanilla',
515 'itempool' => 'Standard',
517 'grahm' => 'BookSouls',
519 'startshop' => 'Unlocked30k',
520 'shopprice' => 'RandHV',
521 'shopSouls' => 'Half',
522 'levelexp' => 'Vanilla',
523 'telestart' => 'false',
524 'mapassist' => 'false',
525 'doublechaos' => 'false',
526 'reqallsouls' => 'false',
528 'palette' => 'Vanilla',
531 'Tournament2022' => [
532 'name' => 'Tournament 2022',
533 'value' => 'Tournament2022',
535 'logic' => 'AreaTechTiers',
536 'nodupes' => 'false',
537 'panther' => 'FirstAlways',
538 'area' => 'AreaRandom',
539 'boss' => 'Dead-endShuffle',
540 'enemy' => 'Vanilla',
541 'itempool' => 'Standard',
543 'grahm' => 'BookSouls',
545 'startshop' => 'Unlocked30k',
546 'shopprice' => 'RandHV',
547 'shopSouls' => 'Half',
548 'levelexp' => 'Vanilla',
549 'telestart' => 'false',
550 'mapassist' => 'false',
551 'doublechaos' => 'false',
552 'reqallsouls' => 'false',
554 'palette' => 'Vanilla',