Beispiel #1
0
    async def _accept_bounty(self, ctx):
        with open("txt/bounty.txt", "r") as q:
            for line in q:
                line = line.strip()
                if line:
                    bounty = line

        if bounty == "0":
            await ctx.send("There is no bounty to accept")
            return

        users = get_bank_data()
        user = ctx.author

        try:
            activebounty = users[str(user.id)]["bounty"]["active"]
            rewardbounty = users[str(user.id)]["bounty"]["reward"]
        except KeyError:
            users[str(user.id)]["bounty"] = {}
            users[str(user.id)]["bounty"]["active"] = False
            users[str(user.id)]["bounty"]["reward"] = 0

            with open("mainbank.json", "w") as f:
                json.dump(users, f)

            users = get_bank_data()
            activebounty = users[str(user.id)]["bounty"]["active"]
            rewardbounty = users[str(user.id)]["bounty"]["reward"]

        if activebounty == True:
            await ctx.send("You already have an active bounty")
            return

        users[str(user.id)]["bounty"]["active"] = True
        users[str(user.id)]["bounty"]["reward"] = bounty

        with open("mainbank.json", "w") as f:
            json.dump(users, f)
        await ctx.send("You accepted the bounty")

        with open("txt/bounty.txt", "w") as f:
            f.write("0")
            f.close
Beispiel #2
0
    async def _balance(self, ctx):
        open_account(ctx.author)
        user = ctx.author
        users = get_bank_data()

        bal_amt = users[str(user.id)]["balance"]

        em = discord.Embed(title = f"{ctx.author.name}'s balance", color = discord.Color.dark_gold())
        em.add_field(name = "Credits", value = bal_amt)
        await ctx.send(embed = em)
Beispiel #3
0
    async def _buy_item(self, ctx, ID=None, amount=1):
        open_account(ctx.author)
        open_inventory(ctx.author)
        user = ctx.author
        users = get_bank_data()
        i_users = get_inventory_data()

        userbal = users[str(user.id)]["balance"]

        if ID == None:
            em = discord.Embed(description="Use `!buy <id> <amount>`",
                               color=discord.Color.blue())
        else:

            for item in shop_options:
                if item["id"] == ID:
                    price = item["price"]
                    name = item["name"]
                    break
                name = None

            if name == None:
                await ctx.send("Put an ID")
                return

            if amount <= 0:
                await ctx.send(f"You cannot buy less then 1 {name}")
                return

            total = price * amount

            if amount == 1:
                more = ""
            else:
                more = "'s"

            if userbal < total:
                await ctx.send(
                    f"You need at least {total} creditss to buy {amount} {name}{more}"
                )
                return

            users[str(user.id)]["balance"] -= total
            i_users[str(user.id)][name] += amount
            em = discord.Embed(
                description=
                f"You bought {amount} {name}{more} and payed {total} credits.",
                color=discord.Color.blue())

        with open("inventory.json", "w") as f:
            json.dump(i_users, f)
        with open("mainbank.json", "w") as f:
            json.dump(users, f)
        await ctx.send(embed=em)
Beispiel #4
0
 async def _steal_wallet(self, ctx):
     role = discord.utils.get(ctx.message.guild.roles, name='Citizen')
     if not role in ctx.author.roles:
         await ctx.send("Only citizens can steal")
         return
     open_account(ctx.author)
     user = ctx.author
     users = get_bank_data()
     earnings = random.randrange(50)
     await ctx.send(f"You stole {earnings} credits")
     users[str(user.id)]["balance"] += earnings
     with open("mainbank.json", "w") as f:
         json.dump(users, f)
Beispiel #5
0
    async def _bounty(self, ctx):

        users = get_bank_data()
        user = ctx.author
        name_b = random.choice(name_bounty)

        role = discord.utils.get(ctx.message.guild.roles, name='Bounty Hunter')

        if not role in ctx.author.roles:
            await ctx.author.send("You are not a bounty hunter")
            return

        reward = random.randint(100, 500)
        with open("txt/bounty.txt", "w") as f:
            f.write(str(reward))
            f.close

        embed = discord.Embed(title=name_b,
                              description=reward,
                              color=discord.Colour.green())
        msg = await ctx.author.send(embed=embed)
Beispiel #6
0
 async def _kill_bounty(self, ctx):
     role = discord.utils.get(ctx.message.guild.roles, name='Bounty Hunter')
     if not role in ctx.author.roles:
         await ctx.send("Only bounty hunters can kill the bounty")
         return
     
     busted = random.randrange(100)
     if busted < 25:
         earnings = -300
         em = discord.Embed(title = f"{ctx.author.name} got caught", description = f"You got caught and **{earnings} credits** got taken away", color = discord.Color.dark_green())
         await ctx.send(embed = em)
     else:
         earnings = random.randrange(200, 400)
         em = discord.Embed(title = f"{ctx.author.name} eliminated the bounty", description = f"You brought in the bounty and got paid **{earnings} credits**", color = discord.Color.dark_green())
         await ctx.send(embed = em)
     open_account(ctx.author)
     user = ctx.author
     users = get_bank_data()
     users[str(user.id)]["balance"] += earnings
     with open("mainbank.json", "w") as f:
         json.dump(users, f)