async def send_exp(self, ctx: MyContext, target: discord.Member,
                       amount: int):
        """
        Send some of your experience to another player.
        """
        _, db_channel, db_sender, db_reciver = await asyncio.gather(
            ctx.get_translate_function(), get_from_db(ctx.channel),
            get_player(ctx.author, ctx.channel),
            get_player(target, ctx.channel))

        if target.id == ctx.author.id:
            await ctx.reply(_("❌ You cant send experience to yourself."))
            return False

        elif target.bot:
            await ctx.reply(
                _("❌ I'm not sure that {target.mention} can play DuckHunt.",
                  target=target))
            return False

        elif amount < 10:
            await ctx.reply(_("❌ You need to send more experience than this."))
            return False

        elif db_sender.experience < amount:
            await ctx.reply(_("❌ You don't have enough experience 🤣."))
            return False

        if amount >= 30 and db_reciver.is_powerup_active('confiscated'):
            db_sender.stored_achievements['gun_insurer'] = True

        tax = int(amount * (db_channel.tax_on_user_send / 100) + 0.5)

        await db_sender.edit_experience_with_levelups(ctx, -amount)
        await db_reciver.edit_experience_with_levelups(ctx, amount - tax)

        await asyncio.gather(db_sender.save(), db_reciver.save())

        await ctx.reply(
            _(
                "🏦 You sent {recived} experience to {reciver.mention}. "
                "A tax of {db_channel.tax_on_user_send}% was applied to this transaction (taking {tax} exp out of the total sent).",
                amount=amount,
                recived=amount - tax,
                tax=tax,
                reciver=target,
                db_channel=db_channel))
Ejemplo n.º 2
0
    async def give_exp(self, ctx: MyContext, target: discord.Member, amount: int):
        """
        Give some experience to another player. This is a cheat.
        """
        _, db_receiver = await asyncio.gather(ctx.get_translate_function(), get_player(target, ctx.channel))

        if target.bot:
            await ctx.reply(_("❌ I'm not sure that {target.mention} can play DuckHunt.", target=target))
            return False

        await db_receiver.edit_experience_with_levelups(ctx, amount)

        await db_receiver.save()

        await ctx.reply(_("💰️ You gave {amount} experience to {reciver.mention}. ",
                          amount=amount,
                          reciver=target, ))