예제 #1
0
    async def switch(self, ctx, *args):
        characters = cm.get_player_characters_list(ctx.author.id)
        if len(characters) < 2:
            await ctx.send(
                "You have less than 2 imported characters. Use `?chars` to list your characters"
            )
            return
        _, active_char = cm.get_active_char(ctx.author.id)
        msg_text = mf.format_characters(characters,
                                        ctx.author,
                                        active_char['_id'],
                                        choosing=True)
        await ctx.send(msg_text)

        async def on_reply(reply):
            try:
                index = int(reply) - 1
                new_id = characters[index]['id']
                char = characters[index]
                success_msg = "{0} set your active character to: {1}".format(
                    ctx.author.mention, char['name'])
                if cm.switch_active_character(ctx.author.id, new_id):
                    await ctx.send(success_msg)
            except ValueError:
                await ctx.send(
                    "Please input a number. Switching Canceled. Use `?switch` again"
                )

        rep = rh.ReplyHolder(ctx.author.id, on_reply)
        rh.replies.append(rep)
예제 #2
0
 async def chars(self, ctx, *arg):
     status, active_char = cm.get_active_char(ctx.author.id)
     if status == cm.STATUS_ERR:
         await ctx.send(
             "Could not retrieve your characters. Have you imported any yet?"
         )
         return
     characters = cm.get_player_characters_list(ctx.author.id)
     msg_text = mf.format_characters(characters, ctx.author,
                                     active_char['_id'])
     await ctx.send(msg_text)
예제 #3
0
 async def join(self, ctx):
     if self.bot.cached_combat is None:
         await ctx.send('Combat has not started!')
     else:  # Check if player has a player!
         status, cha = cm.get_active_char(ctx.author.id)
         if status == cm.STATUS_ERR:
             await ctx.send("You haven't imported a character!")
         else:
             i = await roll_initiative(ctx, cha)
             cbt = Combatant(cha['name'], i, True, ctx.author.mention,
                             cha['HPMax'], cha['HP'])
             print("ADDED A COMBATANT YA LATIF {0}".format(cbt))
             self.bot.cached_combat.add_char(cbt)
             await self.bot.cached_combat.cached_summary.edit(
                 content=self.bot.cached_combat.get_full_text())
예제 #4
0
    async def chimport(self, ctx):

        if hasattr(ctx.message, 'attachments') and len(
                ctx.message.attachments) == 1:
            await ctx.send(
                "Importing character. Please wait while I download your character :p"
            )
            json_bytes = await ctx.message.attachments[0].read()
            status = cm.import_from_json(json_bytes, ctx.author.id)
            if status == cm.STATUS_OK:
                _, char = cm.get_active_char(ctx.author.id)
                await ctx.send('Imported ' + char['name'])
            elif status == cm.STATUS_ERR:
                await ctx.send(
                    'There was an error while importing the character. Check logs!'
                )
        else:
            await ctx.send('You need to upload your printed PDF')
예제 #5
0
    async def hp(self, ctx, *args):
        status, cha = cm.get_active_char(ctx.author.id)
        if status == cm.STATUS_ERR:
            ctx.send("3mol ma3roof import a character first. mK? thanks!")
        else:
            if len(args) == 0:
                await ctx.send('{0}: {1}/{2}'.format(cha['name'], cha['HP'],
                                                     cha['HPMax']))
            else:
                mod = int(args[0])
                cm.update_character_hp(cha, mod)

                if self.bot.cached_combat is None:
                    await ctx.send('{0}: {1}/{2}'.format(
                        cha['name'], cha['HP'], cha['HPMax']))
                else:
                    cbt = self.bot.cached_combat.get_combatant_from_name(
                        cha['name'])
                    cbt.modify_health(mod)
                    await ctx.send(cbt.get_summary())
                    await self.bot.cached_combat.cached_summary.edit(
                        content=self.bot.cached_combat.get_full_text())