async def autochar(self, ctx, level):
        """Automagically creates a dicecloud sheet for you, with basic character information complete."""
        try:
            level = int(level)
        except:
            await self.bot.say("Invalid level.")
            return
        if level > 20 or level < 1:
            await self.bot.say("Invalid level (must be 1-20).")
            return

        author = ctx.message.author
        channel = ctx.message.channel

        await self.bot.say(author.mention + " What race?")
        race_response = await self.bot.wait_for_message(timeout=90, author=author, channel=channel)
        if race_response is None: return await self.bot.say("Race not found.")
        race = await search_and_select(ctx, c.fancyraces, race_response.content, lambda e: e.name)

        await self.bot.say(author.mention + " What class?")
        class_response = await self.bot.wait_for_message(timeout=90, author=author, channel=channel)
        if class_response is None: return await self.bot.say("Class not found.")
        result = searchClass(class_response.content)
        if result is None: return await self.bot.say("Class not found.")
        _class = await resolve(result, ctx)

        if 'subclasses' in _class:
            await self.bot.say(author.mention + " What subclass?")
            subclass_response = await self.bot.wait_for_message(timeout=90, author=author, channel=channel)
            if subclass_response is None: return await self.bot.say("Subclass not found.")
            result = fuzzywuzzy_search_all_3(_class['subclasses'], 'name', subclass_response.content)
            subclass = await resolve(result, ctx)
        else:
            subclass = None

        await self.bot.say(author.mention + " What background?")
        bg_response = await self.bot.wait_for_message(timeout=90, author=author, channel=channel)
        if bg_response is None: return await self.bot.say("Background not found.")
        result = searchBackground(bg_response.content)
        background = await resolve(result, ctx)

        userId = None
        for _ in range(2):
            await self.bot.say(author.mention + " What is your dicecloud username?")
            user_response = await self.bot.wait_for_message(timeout=60, author=author, channel=channel)
            if user_response is None: return await self.bot.say("Timed out waiting for a response.")
            username = user_response.content
            try:
                userId = await DicecloudClient.getInstance().get_user_id(username)
            except MeteorClientException:
                pass
            if userId: break
            await self.bot.say(
                "Dicecloud user not found. Maybe try your email, or putting it all lowercase if applicable.")

        if userId is None:
            return await self.bot.say("Invalid dicecloud username.")

        await self.createCharSheet(ctx, level, userId, race, _class, subclass, background)
Esempio n. 2
0
    async def char(self, ctx, level):
        """Gives you reference stats for a 5e character."""
        try:
            level = int(level)
        except:
            await self.bot.say("Invalid level.")
            return
        if level > 20 or level < 1:
            await self.bot.say("Invalid level (must be 1-20).")
            return

        author = ctx.message.author
        channel = ctx.message.channel

        await self.bot.say(author.mention + " What race?")
        race_response = await self.bot.wait_for_message(timeout=90,
                                                        author=author,
                                                        channel=channel)
        if race_response is None: return await self.bot.say("Race not found.")
        race = await search_and_select(ctx, c.fancyraces,
                                       race_response.content, lambda e: e.name)

        await self.bot.say(author.mention + " What class?")
        class_response = await self.bot.wait_for_message(timeout=90,
                                                         author=author,
                                                         channel=channel)
        if class_response is None:
            return await self.bot.say("Class not found.")
        result = searchClass(class_response.content)
        if result is None: return await self.bot.say("Class not found.")
        _class = await resolve(result, ctx)

        if 'subclasses' in _class:
            await self.bot.say(author.mention + " What subclass?")
            subclass_response = await self.bot.wait_for_message(
                timeout=90, author=author, channel=channel)
            if subclass_response is None:
                return await self.bot.say("Subclass not found.")
            result = fuzzywuzzy_search_all_3(_class['subclasses'], 'name',
                                             subclass_response.content)
            subclass = await resolve(result, ctx)
        else:
            subclass = None

        await self.bot.say(author.mention + " What background?")
        bg_response = await self.bot.wait_for_message(timeout=90,
                                                      author=author,
                                                      channel=channel)
        if bg_response is None:
            return await self.bot.say("Background not found.")
        result = searchBackground(bg_response.content)
        background = await resolve(result, ctx)

        await self.genChar(ctx, level, race, _class, subclass, background)
Esempio n. 3
0
def searchAutoSpell(name):
    return fuzzywuzzy_search_all_3(c.autospells, 'name', name)
Esempio n. 4
0
def searchSpell(name):
    return fuzzywuzzy_search_all_3(c.spells, 'name', name, return_key=True)
Esempio n. 5
0
def searchBackground(name):
    return fuzzywuzzy_search_all_3(c.backgrounds, 'name', name)
Esempio n. 6
0
def searchClass(name):
    return fuzzywuzzy_search_all_3(c.classes, 'name', name)