Skip to content

Commit

Permalink
Define common seed options in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
tesence committed Nov 20, 2024
1 parent dac9ade commit ac74643
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 52 deletions.
25 changes: 25 additions & 0 deletions gumo/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,28 @@
VARIATION_CHOICES = [app_commands.Choice(name=name, value=name) for name, value in VARIATIONS.items()]
LOGIC_PATH_CHOICES = [app_commands.Choice(name=name, value=name) for name, value in LOGIC_PATHS.items()]
ITEM_POOL_CHOICES = [app_commands.Choice(name=name, value=name) for name, value in ITEM_POOLS.items()]

def add_seed_options(func):
"""Set all the common options for seed commands
Args:
func (function): Command definition
"""
func = app_commands.describe(logic_mode="Randomizer logic mode")(func)
func = app_commands.choices(logic_mode=LOGIC_MODE_CHOICES)(func)
func = app_commands.describe(key_mode="Randomizer key mode")(func)
func = app_commands.choices(key_mode=KEY_MODE_CHOICES)(func)
func = app_commands.describe(goal_mode="Randomizer goal mode")(func)
func = app_commands.choices(goal_mode=GOAL_MODE_CHOICES)(func)
func = app_commands.describe(spawn="The location where the player starts in the seed")(func)
func = app_commands.choices(spawn=SPAWN_CHOICES)(func)
func = app_commands.describe(variation1="Extra randomizer variation")(func)
func = app_commands.choices(variation1=VARIATION_CHOICES)(func)
func = app_commands.describe(variation2="Extra randomizer variation")(func)
func = app_commands.choices(variation2=VARIATION_CHOICES)(func)
func = app_commands.describe(variation3="Extra randomizer variation")(func)
func = app_commands.choices(variation3=VARIATION_CHOICES)(func)
func = app_commands.describe(item_pool="Randomizer item pool")(func)
func = app_commands.choices(item_pool=ITEM_POOL_CHOICES)(func)
func = app_commands.describe(relic_count="(World Tour only) The number of relics to place in the seed")(func)
return func
18 changes: 1 addition & 17 deletions gumo/modules/league.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,7 @@ async def _submit(self, *submissions):
league = app_commands.Group(name="league", description="BF Rando League commands")

@league.command(name='set')
@app_commands.describe(logic_mode="Randomizer logic mode")
@app_commands.choices(logic_mode=models.LOGIC_MODE_CHOICES)
@app_commands.describe(key_mode="Randomizer key mode")
@app_commands.choices(key_mode=models.KEY_MODE_CHOICES)
@app_commands.describe(goal_mode="Randomizer goal mode")
@app_commands.choices(goal_mode=models.GOAL_MODE_CHOICES)
@app_commands.describe(spawn="Start location")
@app_commands.choices(spawn=models.SPAWN_CHOICES)
@app_commands.describe(variation1="Extra randomizer variation")
@app_commands.choices(variation1=models.VARIATION_CHOICES)
@app_commands.describe(variation2="Extra randomizer variation")
@app_commands.choices(variation2=models.VARIATION_CHOICES)
@app_commands.describe(variation3="Extra randomizer variation")
@app_commands.choices(variation3=models.VARIATION_CHOICES)
@app_commands.describe(item_pool="Randomizer item pool")
@app_commands.choices(item_pool=models.ITEM_POOL_CHOICES)
@app_commands.describe(relic_count="(World Tour only) The number of relics to place in the seed")
@models.add_seed_options
@app_commands.describe(date="The settings of the week to be set")
@app_commands.check(is_league_admin_check)
# pylint: disable=unused-argument
Expand Down
37 changes: 2 additions & 35 deletions gumo/modules/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

logger = logging.getLogger(__name__)


class BFRandomizer(commands.Cog, name="Blind Forest Randomizer"):
"""Custom Cog"""

Expand All @@ -29,23 +28,7 @@ def __init__(self, bot):

@app_commands.command(name='seed')
@app_commands.describe(seed_name="A string to be used as seed")
@app_commands.describe(logic_mode="Randomizer logic mode")
@app_commands.choices(logic_mode=models.LOGIC_MODE_CHOICES)
@app_commands.describe(key_mode="Randomizer key mode")
@app_commands.choices(key_mode=models.KEY_MODE_CHOICES)
@app_commands.describe(goal_mode="Randomizer goal mode")
@app_commands.choices(goal_mode=models.GOAL_MODE_CHOICES)
@app_commands.describe(spawn="The location where the player starts in the seed")
@app_commands.choices(spawn=models.SPAWN_CHOICES)
@app_commands.describe(variation1="Extra randomizer variation")
@app_commands.choices(variation1=models.VARIATION_CHOICES)
@app_commands.describe(variation2="Extra randomizer variation")
@app_commands.choices(variation2=models.VARIATION_CHOICES)
@app_commands.describe(variation3="Extra randomizer variation")
@app_commands.choices(variation3=models.VARIATION_CHOICES)
@app_commands.describe(item_pool="Randomizer item pool")
@app_commands.choices(item_pool=models.ITEM_POOL_CHOICES)
@app_commands.describe(relic_count="(World Tour only) The number of relics to place in the seed")
@models.add_seed_options
# pylint: disable=unused-argument
async def seed(self, interaction: discord.Interaction,
seed_name: Optional[str] = None,
Expand Down Expand Up @@ -81,23 +64,7 @@ async def seed(self, interaction: discord.Interaction,
return await interaction.followup.send(content=message, files=[file])

@app_commands.command(name='daily')
@app_commands.describe(logic_mode="Randomizer logic mode")
@app_commands.choices(logic_mode=models.LOGIC_MODE_CHOICES)
@app_commands.describe(key_mode="Randomizer key mode")
@app_commands.choices(key_mode=models.KEY_MODE_CHOICES)
@app_commands.describe(goal_mode="Randomizer goal mode")
@app_commands.choices(goal_mode=models.GOAL_MODE_CHOICES)
@app_commands.describe(spawn="Start location")
@app_commands.choices(spawn=models.SPAWN_CHOICES)
@app_commands.describe(variation1="Extra randomizer variation")
@app_commands.choices(variation1=models.VARIATION_CHOICES)
@app_commands.describe(variation2="Extra randomizer variation")
@app_commands.choices(variation2=models.VARIATION_CHOICES)
@app_commands.describe(variation3="Extra randomizer variation")
@app_commands.choices(variation3=models.VARIATION_CHOICES)
@app_commands.describe(item_pool="Randomizer item pool")
@app_commands.choices(item_pool=models.ITEM_POOL_CHOICES)
@app_commands.describe(relic_count="(World Tour only) The number of relics to place in the seed")
@models.add_seed_options
# pylint: disable=unused-argument
async def daily(self, interaction: discord.Interaction,
logic_mode: Optional[app_commands.Choice[str]] = None,
Expand Down

0 comments on commit ac74643

Please sign in to comment.