Example #1
0
    async def monster_save(self, ctx, monster_name, save_stat, *args):
        await try_delete(ctx.message)
        monster: Monster = await select_monster_full(ctx, monster_name)
        args = await helpers.parse_snippets(args, ctx, statblock=monster)
        args = argparse(args)

        embed = discord.Embed()
        embed.colour = random.randint(0, 0xffffff)
        if not args.last('h', type_=bool):
            embed.set_thumbnail(url=monster.get_image_url())

        checkutils.run_save(save_stat, monster, args, embed)

        handle_source_footer(embed, monster, add_source_str=False)

        await ctx.send(embed=embed)
Example #2
0
    async def save(self, ctx, skill, *args):
        if skill == 'death':
            ds_cmd = self.bot.get_command('game deathsave')
            if ds_cmd is None:
                return await ctx.send("Error: GameTrack cog not loaded.")
            return await ctx.invoke(ds_cmd, *args)

        char: Character = await Character.from_ctx(ctx)

        args = await self.new_arg_stuff(args, ctx, char)

        hide = args.last('h', type_=bool)

        embed = embeds.EmbedWithCharacter(char, name=False, image=not hide)

        checkutils.update_csetting_args(char, args)
        caster = await targetutils.maybe_combat_caster(ctx, char)

        result = checkutils.run_save(skill, caster, args, embed)

        # send
        await ctx.send(embed=embed)
        await try_delete(ctx.message)
        if gamelog := self.bot.get_cog('GameLog'):
            await gamelog.send_save(ctx, char, result.skill_name, result.rolls)
Example #3
0
    async def game_deathsave(self, ctx, *args):
        """Commands to manage character death saves.
        __Valid Arguments__
        See `!help save`."""
        character: Character = await Character.from_ctx(ctx)

        embed = EmbedWithCharacter(character, name=False)

        args = await helpers.parse_snippets(args, ctx)
        args = await helpers.parse_with_character(ctx, character, args)
        args = argparse(args)
        checkutils.update_csetting_args(character, args)
        caster, _, _ = await targetutils.maybe_combat(ctx, character, args)
        result = checkutils.run_save('death', caster, args, embed)

        dc = result.skill_roll_result.dc or 10
        death_phrase = ''

        for save_roll in result.skill_roll_result.rolls:
            if save_roll.crit == d20.CritType.CRIT:
                character.hp = 1
            elif save_roll.crit == d20.CritType.FAIL:
                character.death_saves.fail(2)
            elif save_roll.total >= dc:
                character.death_saves.succeed()
            else:
                character.death_saves.fail()

            if save_roll.crit == d20.CritType.CRIT:
                death_phrase = f"{character.name} is UP with 1 HP!"
                break
            elif character.death_saves.is_dead():
                death_phrase = f"{character.name} is DEAD!"
                break
            elif character.death_saves.is_stable():
                death_phrase = f"{character.name} is STABLE!"
                break

        if death_phrase:
            embed.set_footer(text=death_phrase)
        embed.add_field(name="Death Saves",
                        value=str(character.death_saves),
                        inline=False)

        await character.commit(ctx)
        await ctx.send(embed=embed)
        await try_delete(ctx.message)
        if gamelog := self.bot.get_cog('GameLog'):
            await gamelog.send_save(ctx, character, result.skill_name,
                                    result.rolls)