Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cogs/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
from .runecraft import RunecraftCommands
from .recipe import RecipeCommands
from .adventure import AdventureCommands
from .general import GeneralCommands
from .general import GeneralCommands
from .clues import ClueCommands
47 changes: 47 additions & 0 deletions cogs/cmd/clues.py
Original file line number Diff line number Diff line change
@@ -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)
28 changes: 3 additions & 25 deletions cogs/miniscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Miniscape(commands.Cog,
RunecraftCommands,
RecipeCommands,
AdventureCommands,
GeneralCommands):
GeneralCommands,
ClueCommands):
"""Defines Miniscape commands."""

def __init__(self, bot):
Expand All @@ -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):
Expand Down