diff --git a/cogs/cmd/__init__.py b/cogs/cmd/__init__.py index b994bc4..874aa44 100644 --- a/cogs/cmd/__init__.py +++ b/cogs/cmd/__init__.py @@ -6,4 +6,5 @@ from .runecraft import RunecraftCommands from .recipe import RecipeCommands from .adventure import AdventureCommands -from .general import GeneralCommands \ No newline at end of file +from .general import GeneralCommands +from .clues import ClueCommands \ No newline at end of file diff --git a/cogs/cmd/clues.py b/cogs/cmd/clues.py new file mode 100644 index 0000000..dd6bd6e --- /dev/null +++ b/cogs/cmd/clues.py @@ -0,0 +1,47 @@ + +from discord.ext import commands +import miniscape.clue_helpers as clue_helpers +from cogs.cmd.common import has_post_permission + +difficulty_names = { + 'easy': 1, + 'medium': 2, + 'hard': 3, + 'elite': 4, + 'master': 5 +} + +class ClueCommands: + + @commands.group(aliases=['clues'], invoke_without_command=True) + async def clue(self, ctx, difficulty): + """Starts a clue scroll.""" + if has_post_permission(ctx.guild.id, ctx.channel.id): + if not difficulty.isdigit(): + if difficulty not in set(difficulty_names.keys()): + await ctx.send(f'Error: {difficulty} not valid clue scroll difficulty.') + return + parsed_difficulty = difficulty_names[difficulty] + else: + if not 0 < int(difficulty) < 6: + await ctx.send(f'Error: {difficulty} not valid clue scroll difficulty.') + return + parsed_difficulty = int(difficulty) + out = clue_helpers.start_clue(ctx.guild.id, ctx.channel.id, ctx.author.id, + parsed_difficulty) + await ctx.send(out) + + @clue.command(name='loot') + async def _clue_loot(self, ctx, difficulty): + if has_post_permission(ctx.guild.id, ctx.channel.id): + if difficulty not in set(difficulty_names.keys()): + await ctx.send(f'Error: {difficulty} not valid clue scroll difficulty.') + return + parsed_difficulty = difficulty_names[difficulty] + item = Item.objects.get(name__iexact=difficulty) + table = clue_helpers.get_loot_table(item) + out = "" + for i in table: + out += f"{i.loot_item}\n" + + await ctx.send(out) \ No newline at end of file diff --git a/cogs/miniscape.py b/cogs/miniscape.py index 3a7ae23..1a03b8a 100755 --- a/cogs/miniscape.py +++ b/cogs/miniscape.py @@ -28,7 +28,8 @@ class Miniscape(commands.Cog, RunecraftCommands, RecipeCommands, AdventureCommands, - GeneralCommands): + GeneralCommands, + ClueCommands): """Defines Miniscape commands.""" def __init__(self, bot): @@ -47,30 +48,7 @@ async def bestiary(self, ctx, *args): messages = mon.print_monster(monster) await self.paginate(ctx, messages) - @commands.group(aliases=['clues'], invoke_without_command=True) - async def clue(self, ctx, difficulty): - """Starts a clue scroll.""" - if has_post_permission(ctx.guild.id, ctx.channel.id): - if not difficulty.isdigit(): - difficulty_names = { - 'easy': 1, - 'medium': 2, - 'hard': 3, - 'elite': 4, - 'master': 5 - } - if difficulty not in set(difficulty_names.keys()): - await ctx.send(f'Error: {difficulty} not valid clue scroll difficulty.') - return - parsed_difficulty = difficulty_names[difficulty] - else: - if not 0 < int(difficulty) < 6: - await ctx.send(f'Error: {difficulty} not valid clue scroll difficulty.') - return - parsed_difficulty = int(difficulty) - out = clue_helpers.start_clue(ctx.guild.id, ctx.channel.id, ctx.author.id, - parsed_difficulty) - await ctx.send(out) + @commands.command() async def gather(self, ctx, *args):