Skip to content

Commit 219d494

Browse files
committed
Switch to application commands
1 parent b1d7399 commit 219d494

File tree

12 files changed

+341
-440
lines changed

12 files changed

+341
-440
lines changed

.editorconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ indent_style = space
77
indent_size = 4
88
insert_final_newline = true
99
trim_trailing_whitespace = true
10-
11-
[*.md]
12-
max_line_length = off
13-
trim_trailing_whitespace = false

gumo/api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .base import APIError
1+
from .core import BFRandomizerApiClient, SEEDGEN_API_URL

gumo/api/base.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

gumo/api/bf_randomizer.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

gumo/api/core.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import logging
2+
from urllib import parse
3+
4+
import aiohttp
5+
6+
from gumo.api import models
7+
8+
logger = logging.getLogger(__name__)
9+
10+
SEEDGEN_API_URL = "https://orirando.com"
11+
12+
PATHS_INHERITENCE = {}
13+
PATHS_INHERITENCE['Casual'] = [v for k, v in models.LOGIC_PATHS.items() if k.startswith('Casual')]
14+
PATHS_INHERITENCE['Standard'] = PATHS_INHERITENCE['Casual'] + \
15+
[v for k, v in models.LOGIC_PATHS.items() if k.startswith('Standard')]
16+
PATHS_INHERITENCE['Expert'] = PATHS_INHERITENCE['Standard'] + \
17+
[v for k, v in models.LOGIC_PATHS.items() if k.startswith('Expert')] + \
18+
[models.LOGIC_PATHS['Dbash']]
19+
PATHS_INHERITENCE['Master'] = PATHS_INHERITENCE['Expert'] + \
20+
[v for k, v in models.LOGIC_PATHS.items() if k.startswith('Master')]
21+
PATHS_INHERITENCE['Glitched'] = PATHS_INHERITENCE['Expert'] + \
22+
[models.LOGIC_PATHS['Glitched'], models.LOGIC_PATHS['Timed-Level']]
23+
24+
25+
class BFRandomizerApiClient:
26+
27+
28+
def __init__(self, *args, **kwargs):
29+
self._session = aiohttp.ClientSession(*args, **kwargs, raise_for_status=True)
30+
31+
32+
async def get_data(self, seed_name, logic_mode=None, key_mode=None, goal_mode=None, spawn=None, variations=(),
33+
item_pool=None):
34+
35+
params = {('seed', seed_name)}
36+
37+
for path in PATHS_INHERITENCE[logic_mode]:
38+
params.add(('path', path))
39+
40+
params.add(('key_mode', models.KEY_MODES[key_mode]))
41+
params.add(('var', models.GOAL_MODES[goal_mode]))
42+
params.add(('pool_preset', models.ITEM_POOLS[item_pool]))
43+
params.add(('spawn', spawn))
44+
45+
# Variations
46+
for variation in variations:
47+
params.add(('var', models.VARIATIONS[variation]))
48+
49+
# Handle all the preset specificities
50+
if logic_mode == "Casual":
51+
params.add(('cell_freq', "20"))
52+
elif logic_mode == "Standard":
53+
params.add(('cell_freq', "40"))
54+
elif logic_mode == "Expert":
55+
params.add(('cell_freq', "256"))
56+
elif logic_mode == "Master":
57+
params.add(('cell_freq', "256"))
58+
params.add(("path_diff", models.PATH_DIFFICULTIES['Hard']))
59+
params.add(('var', models.VARIATIONS['Starved']))
60+
elif logic_mode == "Glitched":
61+
params.add(('cell_freq', "256"))
62+
params.add(("path_diff", models.PATH_DIFFICULTIES['Hard']))
63+
64+
url = f"{SEEDGEN_API_URL}/generator/json?{parse.urlencode(list(params))}"
65+
logger.debug(f"Outgoing request: {url}")
66+
resp = await self._session.request('GET', url)
67+
return await resp.json()

gumo/api/models.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
LOGIC_MODES = {
2+
'Casual': "Casual",
3+
'Standard': "Standard",
4+
'Expert': "Expert",
5+
'Master': "Master",
6+
'Glitched': "Glitched"
7+
}
8+
9+
KEY_MODES = {
10+
'None': "Default",
11+
'Shards': "Shards",
12+
'Limitkeys': "Limitkeys",
13+
'Clues': "Clues",
14+
'Free': "Free"
15+
}
16+
17+
GOAL_MODES = {
18+
'None': "",
19+
'Force Trees': "ForceTrees",
20+
'World Tour': "WorldTour",
21+
'Force Maps': "ForceMaps",
22+
'Warmth Frags': "WarmthFrags",
23+
'Bingo': "Bingo"
24+
}
25+
26+
SPAWNS = {
27+
'Random': "Random",
28+
'Glades': "Glades",
29+
'Grove': "Grove",
30+
'Swamp': "Swamp",
31+
'Grotto': "Grotto",
32+
'Forlorn': "Forlorn",
33+
'Valley': "Valley",
34+
'Horu': "Horu",
35+
'Ginso': "Ginso",
36+
'Sorrow': "Sorrow",
37+
'Blackroot': "Blackroot"
38+
}
39+
40+
VARIATIONS = {
41+
'Starved': "Starved",
42+
'OHKO': "OHKO",
43+
'0XP': "0XP",
44+
'Closed Dungeons': "ClosedDungeons",
45+
'Extra Copies': "DoubleSkills",
46+
'Strict Mapstones': "StrictMapstones",
47+
'TP Starved': "TPStarved",
48+
'Skip Final Escape': "GoalModeFinish",
49+
'Wall Starved': "WallStarved",
50+
'Grenade Starved': "GrenadeStarved",
51+
'In-Logic Warps': "InLogicWarps"
52+
}
53+
54+
LOGIC_PATHS = {
55+
'Casual-core': "casual-core",
56+
'Casual-dboost': "casual-dboost",
57+
'Standard-core': "standard-core",
58+
'Standard-dboost': "standard-dboost",
59+
'Standard-lure': "standard-lure",
60+
'Standard-abilities': "standard-abilities",
61+
'Expert-core': "expert-core",
62+
'Expert-dboost': "expert-dboost",
63+
'Expert-lure': "expert-lure",
64+
'Expert-abilities': "expert-abilities",
65+
'Master-core': "master-core",
66+
'Master-dboost': "master-dboost",
67+
'Master-lure': "master-lure",
68+
'Dbash': "dbash",
69+
'Gjump': "gjump",
70+
'Glitched': "glitched",
71+
'Timed-Level': "timed-level",
72+
'Insane': "insane"
73+
}
74+
75+
ITEM_POOLS = {
76+
'Standard': "Standard",
77+
'Competitive': "Competitive",
78+
'Bonus Lite': "Bonus Lite",
79+
'Extra Bonus': "Extra Bonus",
80+
'Hard': "Hard"
81+
}
82+
83+
PATH_DIFFICULTIES = {
84+
'Easy': "Easy",
85+
'Normal': "Normal",
86+
'Hard': "Hard"
87+
}

gumo/bot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
MODULES = [
88
"gumo.modules.emoji_chain",
9-
"gumo.modules.help",
109
"gumo.modules.seed"
1110
]
1211

@@ -25,3 +24,7 @@ def __init__(self, *args, **kwargs):
2524
async def setup_hook(self):
2625
for module in MODULES:
2726
await self.load_extension(module)
27+
28+
async def on_ready(self):
29+
synced = await self.tree.sync()
30+
logger.debug(f"Synced commands: {len(synced)}")

gumo/modules/help.py

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)