Beispiel #1
0
    async def adventures(self, ctx):
        """A list of all adventures with success rates, name and time it takes."""
        sword, shield = await self.bot.get_equipped_items_for(ctx.author)
        all_dungeons = list(self.bot.config.adventure_times.keys())
        level = rpgtools.xptolevel(ctx.character_data["xp"])
        damage = sword["damage"] if sword else 0
        defense = shield["armor"] if shield else 0

        msg = await ctx.send("Loading images...")

        chances = []
        for adv in all_dungeons:
            success = rpgtools.calcchance(damage,
                                          defense,
                                          adv,
                                          int(level),
                                          returnsuccess=False)
            chances.append((success[0] - success[2], success[1] + success[2]))
        thing = functools.partial(rpgtools.makeadventures, chances)
        images = await self.bot.loop.run_in_executor(None, thing)

        await msg.delete()

        files = [
            discord.File(img, filename=f"Adventure{idx + 1}.png")
            for idx, img in enumerate(images)
        ]
        pages = [
            discord.Embed().set_image(
                url=f"attachment://Adventure{idx + 1}.png")
            for idx in range(len(images))
        ]

        await self.bot.paginator.AdventurePaginator(embeds=pages,
                                                    files=files).paginate(ctx)
Beispiel #2
0
    async def adventures(self, ctx):
        _(
            """Shows all adventures, their names, descriptions, and your chances to beat them in picture form.
            Your chances are determined by your equipped items, race and class bonuses, your level and your God-given luck."""
        )
        damage, defense = await self.bot.get_damage_armor_for(ctx.author)
        level = rpgtools.xptolevel(ctx.character_data["xp"])
        luck_booster = await self.bot.get_booster(ctx.author, "luck")

        chances = []
        for adv in range(1, 31):
            success = rpgtools.calcchance(
                damage,
                defense,
                adv,
                int(level),
                ctx.character_data["luck"],
                booster=luck_booster,
                returnsuccess=False,
            )
            chances.append(success)

        async with self.bot.trusted_session.post(
            f"{self.bot.config.external.okapi_url}/api/genadventures",
            json={"percentages": chances},
            headers={"Authorization": self.bot.config.external.okapi_token},
        ) as r:
            images = await r.json()

        pages = [discord.Embed().set_image(url=image) for image in images]

        await self.bot.paginator.Paginator(extras=pages).paginate(ctx)
Beispiel #3
0
    async def adventures(self, ctx):
        _("""Shows all adventures, their names, descriptions, and your chances to beat them in picture form.
            Your chances are determined by your equipped items, race and class bonuses, your level and your God-given luck."""
          )
        damage, defense = await self.bot.get_damage_armor_for(ctx.author)
        level = rpgtools.xptolevel(ctx.character_data["xp"])
        luck_booster = await self.bot.get_booster(ctx.author, "luck")

        msg = await ctx.send(_("Loading images..."))

        chances = []
        for adv in self.bot.config.adventure_times:
            success = rpgtools.calcchance(
                damage,
                defense,
                adv,
                int(level),
                ctx.character_data["luck"],
                booster=luck_booster,
                returnsuccess=False,
            )
            chances.append((success[0] - success[2], success[1] + success[2]))

        async with self.bot.trusted_session.post(
                f"{self.bot.config.okapi_url}/api/genadventures",
                json={"percentages": chances},
        ) as r:
            images = await r.json()

        await msg.delete()

        files = [
            discord.File(filename=f"Adventure{idx + 1}.png",
                         fp=BytesIO(b64decode(img[22:])))
            for idx, img in enumerate(images)
        ]
        pages = [
            discord.Embed().set_image(
                url=f"attachment://Adventure{idx + 1}.png")
            for idx in range(len(images))
        ]

        await self.bot.paginator.AdventurePaginator(embeds=pages,
                                                    files=files).paginate(ctx)
Beispiel #4
0
    async def adventures(self, ctx):
        _("""A list of all adventures with success rates, name and time it takes."""
          )
        sword, shield = await self.bot.get_equipped_items_for(ctx.author)
        all_dungeons = list(self.bot.config.adventure_times.keys())
        level = rpgtools.xptolevel(ctx.character_data["xp"])
        damage = sword["damage"] if sword else 0
        defense = shield["armor"] if shield else 0

        msg = await ctx.send(_("Loading images..."))

        chances = []
        for adv in all_dungeons:
            success = rpgtools.calcchance(
                damage,
                defense,
                adv,
                int(level),
                ctx.character_data["luck"],
                returnsuccess=False,
            )
            chances.append((success[0] - success[2], success[1] + success[2]))
        async with self.bot.trusted_session.post(
                f"{self.bot.config.okapi_url}/api/genadventures",
                json={"percentages": chances},
        ) as r:
            images = await r.json()

        await msg.delete()

        files = [
            discord.File(filename=f"Adventure{idx + 1}.png",
                         fp=BytesIO(b64decode(img[22:])))
            for idx, img in enumerate(images)
        ]
        pages = [
            discord.Embed().set_image(
                url=f"attachment://Adventure{idx + 1}.png")
            for idx in range(len(images))
        ]

        await self.bot.paginator.AdventurePaginator(embeds=pages,
                                                    files=files).paginate(ctx)
Beispiel #5
0
        damage, armor = await self.bot.get_damage_armor_for(ctx.author)

        luck_booster = await self.bot.get_booster(ctx.author, "luck")
        current_level = int(rpgtools.xptolevel(ctx.character_data["xp"]))
        luck_multiply = ctx.character_data["luck"]
        if (buildings := await
                self.bot.get_city_buildings(ctx.character_data["guild"])):
            bonus = buildings["adventure_building"]
        else:
            bonus = 0
        success = rpgtools.calcchance(
            damage,
            armor,
            num,
            current_level,
            luck_multiply,
            returnsuccess=True,
            booster=bool(luck_booster),
            bonus=bonus,
        )
        await self.bot.delete_adventure(ctx.author)

        if not success:
            await self.bot.pool.execute(
                'UPDATE profile SET "deaths"="deaths"+1 WHERE "user"=$1;',
                ctx.author.id)
            return await ctx.send(_("You died on your mission. Try again!"))

        gold = round(random.randint(20 * num, 60 * num) * luck_multiply)

        if await self.bot.get_booster(ctx.author, "money"):
Beispiel #6
0
    async def status(self, ctx):
        _("""Checks your adventure status.""")
        num, time, done = ctx.adventure_data

        if not done:
            return await ctx.send(
                _("""\
You are currently on an adventure with difficulty `{difficulty}`.
Time until it completes: `{time_left}`
Adventure name: `{adventure}`""").format(
                    difficulty=num,
                    time_left=time,
                    adventure=self.bot.config.adventure_names[num],
                ))

        sword, shield = await self.bot.get_equipped_items_for(ctx.author)
        sword, shield = await self.bot.generate_stats(
            ctx.author,
            sword["damage"] if sword else 0,
            shield["armor"] if shield else 0,
            classes=ctx.character_data["class"],
            race=ctx.character_data["race"],
        )

        luck_booster = await self.bot.get_booster(ctx.author, "luck")
        current_level = int(rpgtools.xptolevel(ctx.character_data["xp"]))
        luck_multiply = ctx.character_data["luck"]
        success = rpgtools.calcchance(
            sword,
            shield,
            num,
            current_level,
            luck_multiply,
            returnsuccess=True,
            booster=bool(luck_booster),
        )
        await self.bot.delete_adventure(ctx.author)

        if not success:
            await self.bot.pool.execute(
                'UPDATE profile SET "deaths"="deaths"+1 WHERE "user"=$1;',
                ctx.author.id)
            return await ctx.send(_("You died on your mission. Try again!"))

        gold = round(
            random.randint(20 * (num - 1) or 1, 60 * (num - 1) or 70) *
            luck_multiply)

        if await self.bot.get_booster(ctx.author, "money"):
            gold = int(gold * 1.25)

        xp = random.randint(250 * num, 500 * num)

        async with self.bot.pool.acquire() as conn:

            if random.randint(1, 10) < 10:
                minstat = round(num * luck_multiply)
                maxstat = round(5 + int(num * 1.5) * luck_multiply)
                item = await self.bot.create_random_item(
                    minstat=minstat if minstat < 35 else 35,
                    maxstat=maxstat if maxstat < 35 else 35,
                    minvalue=round(num * luck_multiply),
                    maxvalue=round(num * 50 * luck_multiply),
                    owner=ctx.author,
                )
            else:
                item = items.get_item()
                await conn.execute(
                    'INSERT INTO loot ("name", "value", "user") VALUES ($1, $2, $3);',
                    item["name"],
                    item["value"],
                    ctx.author.id,
                )

            if (guild := ctx.character_data["guild"]):
                await conn.execute(
                    'UPDATE guild SET "money"="money"+$1 WHERE "id"=$2;',
                    int(gold / 10),
                    guild,
                )

            await conn.execute(
                'UPDATE profile SET "money"="money"+$1, "xp"="xp"+$2, "completed"="completed"+1 WHERE "user"=$3;',
                gold,
                xp,
                ctx.author.id,
            )

            if (partner := ctx.character_data["marriage"]):
                await conn.execute(
                    'UPDATE profile SET "money"="money"+($1*(1+"lovescore"/1000000)) WHERE "user"=$2;',
                    int(gold / 2),
                    partner,
                )
Beispiel #7
0
            race=ctx.character_data["race"],
        )

        luck_booster = await self.bot.get_booster(ctx.author, "luck")
        current_level = int(rpgtools.xptolevel(ctx.character_data["xp"]))
        luck_multiply = ctx.character_data["luck"]
        if (buildings := await
                self.bot.get_city_buildings(ctx.character_data["guild"])):
            bonus = buildings["adventure_building"]
        else:
            bonus = 0
        success = rpgtools.calcchance(
            sword,
            shield,
            num,
            current_level,
            luck_multiply,
            returnsuccess=True,
            booster=bool(luck_booster),
            bonus=bonus,
        )
        await self.bot.delete_adventure(ctx.author)

        if not success:
            await self.bot.pool.execute(
                'UPDATE profile SET "deaths"="deaths"+1 WHERE "user"=$1;',
                ctx.author.id)
            return await ctx.send(_("You died on your mission. Try again!"))

        gold = round(random.randint(20 * num, 60 * num) * luck_multiply)

        if await self.bot.get_booster(ctx.author, "money"):
Beispiel #8
0
    async def status(self, ctx):
        async with self.bot.pool.acquire() as conn:
            ret = await conn.fetchrow(
                'SELECT * FROM mission WHERE "name"=$1;', ctx.author.id
            )
            if not ret:
                return await ctx.send(
                    f"You are on no mission yet. Use `{ctx.prefix}adventure [DungeonID]` to go out on an adventure!"
                )
            isfinished = await conn.fetchrow(
                'SELECT * FROM mission WHERE name=$1 AND clock_timestamp() > "end";',
                ctx.author.id,
            )
            if isfinished:
                sword = await conn.fetchrow(
                    "SELECT ai.* FROM profile p JOIN allitems ai ON (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE i.equipped IS TRUE AND p.user=$1 AND type='Sword';",
                    ctx.author.id,
                )
                shield = await conn.fetchrow(
                    "SELECT ai.* FROM profile p JOIN allitems ai ON (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE i.equipped IS TRUE AND p.user=$1 AND type='Shield';",
                    ctx.author.id,
                )
                playerxp = await conn.fetchval(
                    'SELECT xp FROM profile WHERE "user"=$1;', ctx.author.id
                )
                playerlevel = rpgtools.xptolevel(playerxp)
                try:
                    swordbonus = sword["damage"]
                except KeyError:
                    swordbonus = 0
                try:
                    shieldbonus = shield["armor"]
                except KeyError:
                    shieldbonus = 0

                # class test
                swordbonus, shieldbonus = await genstats(
                    self.bot, ctx.author.id, swordbonus, shieldbonus
                )

                boostertest = await conn.fetchval(
                    'SELECT "end" FROM boosters WHERE "user"=$1 AND "type"=$2;',
                    ctx.author.id,
                    2,
                )
                boostertest2 = await conn.fetchval(
                    'SELECT "end" FROM boosters WHERE "user"=$1 AND "type"=$2 AND clock_timestamp() < "end";',
                    ctx.author.id,
                    2,
                )
                if not boostertest and not boostertest2:
                    success = rpgtools.calcchance(
                        swordbonus,
                        shieldbonus,
                        isfinished[3],
                        int(playerlevel),
                        returnsuccess=True,
                    )
                elif boostertest and not boostertest2:
                    await conn.execute(
                        'DELETE FROM boosters WHERE "user"=$1 AND "type"=$2;',
                        ctx.author.id,
                        2,
                    )
                    success = rpgtools.calcchance(
                        swordbonus,
                        shieldbonus,
                        isfinished[3],
                        int(playerlevel),
                        returnsuccess=True,
                    )
                elif boostertest and boostertest2:
                    success = rpgtools.calcchance(
                        swordbonus,
                        shieldbonus,
                        isfinished[3],
                        int(playerlevel),
                        returnsuccess=True,
                        booster=True,
                    )
                if success:
                    if isfinished[3] < 6:
                        maximumstat = float(random.randint(1, isfinished[3] * 5))
                    else:
                        maximumstat = float(random.randint(1, 25))
                    boostertest = await conn.fetchval(
                        'SELECT "end" FROM boosters WHERE "user"=$1 AND "type"=$2;',
                        ctx.author.id,
                        3,
                    )
                    boostertest2 = await conn.fetchval(
                        'SELECT "end" FROM boosters WHERE "user"=$1 AND "type"=$2 AND clock_timestamp() < "end";',
                        ctx.author.id,
                        3,
                    )
                    if not boostertest and not boostertest2:
                        gold = random.randint(1, 30) * isfinished[3]
                    elif boostertest and not boostertest2:
                        await conn.execute(
                            'DELETE FROM boosters WHERE "user"=$1 AND "type"=$2;',
                            ctx.author.id,
                            3,
                        )
                        gold = random.randint(1, 30) * isfinished[3]
                    elif boostertest and boostertest2:
                        gold = int(random.randint(1, 30) * isfinished[3] * 1.25)
                    xp = random.randint(200, 1000) * isfinished[3]
                    shieldorsword = random.choice(["sw", "sh"])
                    names = [
                        "Victo's",
                        "Arsandor's",
                        "Nuhulu's",
                        "Legendary",
                        "Vosag's",
                        "Mitoa's",
                        "Scofin's",
                        "Skeeren's",
                        "Ager's",
                        "Hazuro's",
                        "Atarbu's",
                        "Jadea's",
                        "Zosus'",
                        "Thocubra's",
                        "Utrice's",
                        "Lingoad's",
                        "Zlatorpian's",
                    ]
                    if shieldorsword == "sw":
                        item = await conn.fetchrow(
                            'INSERT INTO allitems ("owner", "name", "value", "type", "damage", "armor") VALUES ($1, $2, $3, $4, $5, $6) RETURNING *;',
                            ctx.author.id,
                            random.choice(names)
                            + random.choice([" Sword", " Blade", " Stich"]),
                            random.randint(1, 40) * isfinished[3],
                            "Sword",
                            maximumstat,
                            0.00,
                        )
                    if shieldorsword == "sh":
                        item = await conn.fetchrow(
                            'INSERT INTO allitems ("owner", "name", "value", "type", "damage", "armor") VALUES ($1, $2, $3, $4, $5, $6) RETURNING *;',
                            ctx.author.id,
                            random.choice(names)
                            + random.choice([" Shield", " Defender", " Aegis"]),
                            random.randint(1, 40) * isfinished[3],
                            "Shield",
                            0.00,
                            maximumstat,
                        )
                    await conn.execute(
                        'INSERT INTO inventory ("item", "equipped") VALUES ($1, $2);',
                        item[0],
                        False,
                    )
                    # marriage partner should get 50% of the money
                    partner = await conn.fetchval(
                        'SELECT marriage FROM profile WHERE "user"=$1;', ctx.author.id
                    )
                    if partner != 0:
                        await conn.execute(
                            'UPDATE profile SET money=money+$1 WHERE "user"=$2;',
                            int(gold / 2),
                            partner,
                        )
                        # guild money
                    guild = await conn.fetchval(
                        'SELECT guild FROM profile WHERE "user"=$1;', ctx.author.id
                    )
                    if guild != 0:
                        await conn.execute(
                            'UPDATE guild SET money=money+$1 WHERE "id"=$2;',
                            int(gold / 10),
                            guild,
                        )

                    await conn.execute(
                        'UPDATE profile SET money=money+$1 WHERE "user"=$2;',
                        gold,
                        ctx.author.id,
                    )
                    await conn.execute(
                        'UPDATE profile SET xp=xp+$1 WHERE "user"=$2;',
                        xp,
                        ctx.author.id,
                    )
                    await conn.execute(
                        'UPDATE profile SET completed=completed+1 WHERE "user"=$1;',
                        ctx.author.id,
                    )
                    if partner == 0:
                        await ctx.send(
                            f"You have completed your dungeon and received **${gold}** as well as a new weapon: **{item[2]}**. Experience gained: **{xp}**."
                        )
                    else:
                        await ctx.send(
                            f"You have completed your dungeon and received **${gold}** as well as a new weapon: **{item[2]}**. Experience gained: **{xp}**.\nYour partner received **${int(gold/2)}**."
                        )
                else:
                    await ctx.send("You died on your mission. Try again!")
                    await conn.execute(
                        'UPDATE profile SET deaths=deaths+1 WHERE "user"=$1;',
                        ctx.author.id,
                    )
                await conn.execute(
                    'DELETE FROM mission WHERE "name"=$1;', ctx.author.id
                )
            else:
                # mission = await conn.fetchrow('SELECT * FROM mission WHERE name=$1 AND clock_timestamp() < "end";', ctx.author.id)
                mission = ret
                remain = await conn.fetchval("SELECT $1-clock_timestamp();", mission[2])
                dungeon = await conn.fetchrow(
                    "SELECT * FROM dungeon WHERE id=$1;", mission[3]
                )
                await ctx.send(
                    f"You are currently in the adventure with difficulty `{mission[3]}`.\nApproximate end in `{str(remain).split('.')[0]}`\nDungeon Name: `{dungeon[1]}`"
                )
Beispiel #9
0
    async def adventures(self, ctx):
        async with self.bot.pool.acquire() as conn:
            alldungeons = await conn.fetch('SELECT * FROM dungeon ORDER BY "id";')
            sword = await conn.fetchrow(
                "SELECT ai.* FROM profile p JOIN allitems ai ON (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE i.equipped IS TRUE AND p.user=$1 AND type='Sword';",
                ctx.author.id,
            )
            shield = await conn.fetchrow(
                "SELECT ai.* FROM profile p JOIN allitems ai ON (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE i.equipped IS TRUE AND p.user=$1 AND type='Shield';",
                ctx.author.id,
            )
            playerxp = await conn.fetchval(
                'SELECT xp FROM profile WHERE "user"=$1;', ctx.author.id
            )
            playerlevel = rpgtools.xptolevel(playerxp)
            try:
                swordbonus = sword["damage"]
            except KeyError:
                swordbonus = 0
            try:
                shieldbonus = shield["armor"]
            except KeyError:
                shieldbonus = 0
            chances = []
            msg = await ctx.send("Loading images...")
            for row in alldungeons:
                success = rpgtools.calcchance(
                    swordbonus,
                    shieldbonus,
                    row[2],
                    int(playerlevel),
                    returnsuccess=False,
                )
                chances.append((success[0] - success[2], success[1] + success[2]))
            thing = functools.partial(makeadventures, chances)
            images = await self.bot.loop.run_in_executor(None, thing)
            await msg.delete()
            currentpage = 0
            maxpage = len(images) - 1
            f = discord.File(images[currentpage], filename="Adventure.png")
            msg = await ctx.send(
                file=f,
                embed=discord.Embed().set_image(url="attachment://Adventure.png"),
            )
            await msg.add_reaction("\U000023ee")
            await msg.add_reaction("\U000025c0")
            await msg.add_reaction("\U000025b6")
            await msg.add_reaction("\U000023ed")
            await msg.add_reaction("\U0001f522")

            def reactioncheck(reaction, user):
                return (
                    str(reaction.emoji)
                    in [
                        "\U000025c0",
                        "\U000025b6",
                        "\U000023ee",
                        "\U000023ed",
                        "\U0001f522",
                    ]
                    and reaction.message.id == msg.id
                    and user.id == ctx.author.id
                )

            def msgcheck(amsg):
                return amsg.channel == ctx.channel and not amsg.author.bot

            browsing = True
            while browsing:
                try:
                    reaction, user = await self.bot.wait_for(
                        "reaction_add", timeout=60.0, check=reactioncheck
                    )
                    if reaction.emoji == "\U000025c0":
                        if currentpage == 0:
                            pass
                        else:
                            currentpage -= 1
                            await msg.delete()
                            f = discord.File(
                                images[currentpage], filename=f"Adventure.png"
                            )
                            msg = await ctx.send(
                                file=f,
                                embed=discord.Embed().set_image(
                                    url="attachment://Adventure.png"
                                ),
                            )
                    elif reaction.emoji == "\U000025b6":
                        if currentpage == maxpage:
                            pass
                        else:
                            currentpage += 1
                            await msg.delete()
                            f = discord.File(
                                images[currentpage], filename="Adventure.png"
                            )
                            msg = await ctx.send(
                                file=f,
                                embed=discord.Embed().set_image(
                                    url="attachment://Adventure.png"
                                ),
                            )
                    elif reaction.emoji == "\U000023ed":
                        currentpage = maxpage
                        await msg.delete()
                        f = discord.File(images[currentpage], filename="Adventure.png")
                        msg = await ctx.send(
                            file=f,
                            embed=discord.Embed().set_image(
                                url="attachment://Adventure.png"
                            ),
                        )
                    elif reaction.emoji == "\U000023ee":
                        currentpage = 0
                        await msg.delete()
                        f = discord.File(images[currentpage], filename="Adventure.png")
                        msg = await ctx.send(
                            file=f,
                            embed=discord.Embed().set_image(
                                url="attachment://Adventure.png"
                            ),
                        )
                    elif reaction.emoji == "\U0001f522":
                        question = await ctx.send(
                            f"Enter a page number from `1` to `{maxpage+1}`"
                        )
                        num = await self.bot.wait_for(
                            "message", timeout=10, check=msgcheck
                        )
                        if num is not None:
                            try:
                                num2 = int(num.content)
                                if num2 >= 1 and num2 <= maxpage + 1:
                                    currentpage = num2 - 1
                                    await msg.delete()
                                    f = discord.File(
                                        images[currentpage], filename="Adventure.png"
                                    )
                                    msg = await ctx.send(
                                        file=f,
                                        embed=discord.Embed().set_image(
                                            url="attachment://Adventure.png"
                                        ),
                                    )
                                else:
                                    await ctx.send(
                                        f"Must be between `1` and `{maxpage+1}`.",
                                        delete_after=2,
                                    )
                                try:
                                    await num.delete()
                                except discord.Forbidden:
                                    pass
                            except ValueError:
                                await ctx.send("That is no number!", delete_after=2)
                    await question.delete()
                    await msg.add_reaction("\U000023ee")
                    await msg.add_reaction("\U000025c0")
                    await msg.add_reaction("\U000025b6")
                    await msg.add_reaction("\U000023ed")
                    await msg.add_reaction("\U0001f522")
                except asyncio.TimeoutError:
                    browsing = False
                    try:
                        await msg.clear_reactions()
                    except discord.Forbidden:
                        pass
                    finally:
                        break
Beispiel #10
0
    async def status(self, ctx):
        _("""Checks your adventure status.""")
        num, time, done = ctx.adventure_data
        if done:
            sword, shield = await self.bot.get_equipped_items_for(ctx.author)
            playerlevel = rpgtools.xptolevel(ctx.character_data["xp"])

            sword = sword["damage"] if sword else 0
            shield = shield["armor"] if shield else 0

            # class test
            sword, shield = await self.bot.generate_stats(
                ctx.author, sword, shield, class_=ctx.character_data["class"])

            luck_booster = await self.bot.get_booster(ctx.author, "luck")
            success = rpgtools.calcchance(
                sword,
                shield,
                num,
                int(playerlevel),
                returnsuccess=True,
                booster=bool(luck_booster),
            )
            if success:
                gold = random.randint(20 * (num - 1) or 1, 60 * (num - 1)
                                      or 70)
                if await self.bot.get_booster(ctx.author, "money"):
                    gold = int(gold * 1.25)
                xp = random.randint(250 * num, 500 * num)
                item = await self.bot.create_random_item(
                    minstat=num,
                    maxstat=5 + int(num * 1.5),
                    minvalue=num,
                    maxvalue=num * 50,
                    owner=ctx.author,
                )
                async with self.bot.pool.acquire() as conn:
                    # marriage partner should get 50% of the money
                    if ctx.character_data["marriage"]:
                        await conn.execute(
                            'UPDATE profile SET money=money+$1 WHERE "user"=$2;',
                            int(gold / 2),
                            ctx.character_data["marriage"],
                        )
                    # guild money
                    if ctx.character_data["guild"]:
                        await conn.execute(
                            'UPDATE guild SET money=money+$1 WHERE "id"=$2;',
                            int(gold / 10),
                            ctx.character_data["guild"],
                        )
                    await conn.execute(
                        'UPDATE profile SET "money"="money"+$1, "xp"="xp"+$2, "completed"="completed"+1 WHERE "user"=$3;',
                        gold,
                        xp,
                        ctx.author.id,
                    )
                    if not ctx.character_data["marriage"]:
                        await ctx.send(
                            _("You have completed your dungeon and received **${gold}** as well as a new weapon: **{item}**. Experience gained: **{xp}**."
                              ).format(gold=gold, item=item["name"], xp=xp))
                    else:
                        await ctx.send(
                            _("You have completed your dungeon and received **${gold}** as well as a new weapon: **{item}**. Experience gained: **{xp}**.\nYour partner received **${gold2}**."
                              ).format(gold=gold,
                                       gold2=int(gold / 2),
                                       item=item["name"],
                                       xp=xp))
                    new_level = int(
                        rpgtools.xptolevel(ctx.character_data["xp"] + xp))
                    if int(rpgtools.xptolevel(
                            ctx.character_data["xp"])) < new_level:
                        reward = random.choice([
                            (
                                "crates",
                                new_level,
                                _("**{amount}** crates").format(
                                    amount=new_level),
                            ),
                            ("money", new_level * 1000,
                             f"**${new_level * 1000}**"),
                            ("item", round(new_level * 1.5),
                             _("a special Item")),
                        ])
                        if reward[0] != "item":
                            await self.bot.pool.execute(
                                f'UPDATE profile SET {reward[0]}={reward[0]}+$1 WHERE "user"=$2;',
                                reward[1],
                                ctx.author.id,
                            )
                        else:
                            item = await self.bot.create_random_item(
                                minstat=reward[1],
                                maxstat=reward[1],
                                minvalue=1000,
                                maxvalue=1000,
                                owner=ctx.author,
                                insert=False,
                            )
                            item["name"] = _("Level {new_level} Memorial"
                                             ).format(new_level=new_level)
                            await self.bot.create_item(**item)
                        await ctx.send(
                            _("You reached a new level: **{new_level}** :star:! You received {reward} as a reward :tada:!"
                              ).format(new_level=new_level, reward=reward[2]))
            else:
                await ctx.send(_("You died on your mission. Try again!"))
                await self.bot.pool.execute(
                    'UPDATE profile SET deaths=deaths+1 WHERE "user"=$1;',
                    ctx.author.id)
            await self.bot.delete_adventure(ctx.author)
        else:
            dungeon = self.bot.config.adventure_names[num]
            await ctx.send(
                _("You are currently in the adventure with difficulty `{difficulty}`.\nApproximate end in `{end}`\nDungeon Name: `{dungeon}`"
                  ).format(difficulty=num,
                           end=str(time).split(".")[0],
                           dungeon=dungeon))