Example #1
0
 async def _pay(self, ctx, arg0, arg1: int):
     '''Pay someone money'''
     id = ctx.author.id
     #Get the other user
     usr1 = self.bot.get_user(id=int(arg0.strip('!<@').strip('>')))
     if usr1 == None:
         await ctx.send('Could not find that person!')
         return
     if id in currently_trading:
         await ctx.send(
             f"You are currently trading. Please complete the trade to buy."
         )
         return
     await has_account(usr1.id)
     #Bunch of checks
     if arg1 <= 0:
         await ctx.send('Please specify a positive amount.')
         return
     balance = cards_db.get_balance(id)
     if arg1 > balance:
         await ctx.send('You do not have enough Big Bucks!')
         return
     #Update balances
     cards_db.update_balance(id, balance - arg1)
     balance1 = cards_db.get_balance(usr1.id)
     cards_db.update_balance(usr1.id, balance1 + arg1)
     await ctx.send(
         f"Successfully gave **{arg1}** Big Bucks to {usr1.mention}!")
Example #2
0
    async def _buy(self, ctx, arg=''):
        '''Buy a card pack'''
        id = ctx.author.id
        balance = cards_db.get_balance(id)
        pack = arg.capitalize()
        #Check the pack can be bought
        if pack not in PACKS:
            await ctx.send(
                'Please enter a valid card pack!\nCurrent availible packs: Wood, Iron, Gold'
            )
            return
        if PACKS[pack] > balance:
            await ctx.send(
                f'You can not afford the {pack} pack! \nThe pack costs {PACKS[pack]} Big Bucks, but you only have {balance}.'
            )
            return
        if id in currently_trading:
            await ctx.send(
                f"You are currently trading. Please complete the trade to buy."
            )
            return
        #Opens the pack
        items = cards.open_pack(pack)
        cards_db.add_cards(id, items)  #Adds the cards
        cards_db.update_balance(id, balance - PACKS[pack])  #Updates balance
        card_names = '\n'.join(cards.format(items))

        embed = discord.Embed(title=f"🎁 Opened a **{pack}** pack 🎁",
                              color=15834065)
        embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
        embed.add_field(name='**Cards**', value=card_names)
        await ctx.send(embed=embed)
Example #3
0
    async def _sell(self, ctx, *args):
        '''Sell a card for Big Bucks!'''
        id = ctx.author.id
        for arg in args:
            card_info = cards.get_card(arg)
            usr_cards = cards_db.get_cards(id)
            #The card does not exist
            if card_info == None:
                await ctx.send(
                    f"There doesn't seem to be a **{arg}** in our records.")
                continue
            #Check if the user has the card
            if int(card_info['id']) not in usr_cards:
                await ctx.send(
                    f"You don't seem to have a copy of {card_info['name']}.")
                continue
            if id in currently_trading:
                await ctx.send(
                    f"You are currently trading. Please complete the trade to sell."
                )
                continue
            #If they do, remove the card, add the big bucks
            sell_val = CardGame.sell_value(card_info)
            cards_db.remove_card(id, card_info['id'])
            balance = cards_db.get_balance(id)
            cards_db.update_balance(id, balance + sell_val)
            cards_db.add_to_market(card_info['id'])

            embed = discord.Embed(title=f"💰 Sold: **{card_info['name']}** 💰",
                                  color=15834065)
            embed.set_author(name=ctx.author.name,
                             icon_url=ctx.author.avatar_url)
            embed.description = f"Sold the card for {sell_val} Big Bucks."
            await ctx.send(embed=embed)
Example #4
0
 async def _balance(self, ctx):
     '''Displays the balance of the user'''
     id = ctx.author.id
     balance = cards_db.get_balance(id)
     embed = discord.Embed(
         title=f"Current Balance: **{balance}** Big Bucks", color=16744272)
     embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
     embed.description = "Keep typing to earn more money!"
     await ctx.send(embed=embed)
Example #5
0
 async def accept(self,usr):
     i = 0 if usr == self.usrs[0] else 1
     self.confirm[i] = True
     if self.confirm == [True,True]:
         id0 = self.usrs[0].id
         id1 = self.usrs[1].id
         balance0 = cards_db.get_balance(id0)
         balance1 = cards_db.get_balance(id1)
         cards_db.update_balance(id0,balance0 - self.money[0] + self.money[1]) #Updates balance
         cards_db.update_balance(id1,balance1 - self.money[1] + self.money[0]) #Updates balance
         for card_id in self.offers[0]:
             cards_db.remove_card(id0,card_id)
         for card_id in self.offers[1]:
             cards_db.remove_card(id1,card_id)
         cards_db.add_cards(id0,self.offers[1])
         cards_db.add_cards(id1,self.offers[0])
         return True
     await self.channel.send(content=f"{usr.mention} has accepted the current trade. {self.usrs[i*-1+1].mention}, type !trade-accept to accept!")
Example #6
0
 async def on_message(self, ctx):
     #Update a dictionary every message, gaining xp every minute
     id = ctx.author.id
     await has_account(id)
     if id in times:
         if datetime.datetime.utcnow() - times[id] > datetime.timedelta(
                 minutes=1):
             balance = cards_db.get_balance(id)
             cards_db.update_balance(id, balance + random.randint(20, 40))
             times[id] = datetime.datetime.utcnow()
     else:
         times[id] = datetime.datetime.utcnow()
Example #7
0
    async def add(self,usr,args):
        #For each item listed
        i = 0 if usr == self.usrs[0] else 1
        self.confirm = [False,False]
        for arg in args:
            #If it is an int (want to add bigbucks)
            if arg.strip().isdigit():
                val = int(arg)
                balance = cards_db.get_balance(usr.id)
                if val + self.money[i] > balance:
                    await self.channel.send(content=f"You can not afford that! Your current balance is {balance}")
                    continue
                self.money[i] += val
                await self.channel.send(content=f"{usr.mention} added {val} Big Bucks to the trade.")
            else:
            #If it is a card
                if len(self.offers[i]) > 15:
                    await self.channel.send(content=f"Sorry, due to Discord's limits you can only add up to 15 cards to a trade.")
                    continue
                card_info = cards.get_card(arg)
                usr_cards = cards_db.get_cards(usr.id)
                #The card does not exist
                if card_info == None:
                    await self.channel.send(content=f"There doesn't seem to be a **{arg}** in our records.")
                    continue
                #Check if the user has the card
                if int(card_info['id']) not in usr_cards:
                    await self.channel.send(content=f"You don't seem to have a copy of {card_info['name']}.")
                    continue

                count = usr_cards.count(int(card_info['id'])) #Number of the type of card
                offered_count = self.offers[i].count(int(card_info['id'])) #Number of offered
                if offered_count == count:
                    await self.channel.send(content=f"You already offered all **{count}** of your {card_info['name']}'s")
                    continue
                if offered_count > count:
                    await self.channel.send(content=f"Error: You offered more than you have! (Did you trade while trading?)\nRemoved excess offers for {card_info['name']}")
                    for j in range(offered_count-count):
                        self.offers[i].remove(int(card_info['id']))
                    continue
                self.offers[i].append(int(card_info['id']))
                await self.channel.send(content=f"{usr.mention} added {card_info['name']} to the trade.")
        self.embeds[i].set_field_at(index=0,name='Offering:',value=self.get_string(i))
        await self.embed_messages[i].edit(embed=self.embeds[i])
Example #8
0
 async def _market_buy(self, ctx, arg):
     '''Buy a card from the market'''
     id = ctx.author.id
     card_info = cards.get_card(arg)
     market = cards_db.market_cards()
     #The card does not exist
     if card_info == None:
         await ctx.send(
             f"There doesn't seem to be a **{arg}** in our records.")
         return
     #Check if the market has the card
     if int(card_info['id']) not in market:
         await ctx.send(
             f"The market doesn't seem to have a copy of {card_info['name']}."
         )
         return
     if id in currently_trading:
         await ctx.send(
             f"You are currently trading. Please complete the trade to buy from the market."
         )
         return
     buy_val = CardGame.buy_value(card_info)
     balance = cards_db.get_balance(id)
     if buy_val > balance:
         await ctx.send(
             f"You can't afford {card_info['name']}! It costs {buy_val} Big Bucks, but you only have {balance}"
         )
         return
     cards_db.remove_from_market(card_info['id'])
     cards_db.add_cards(id, [card_info['id']])
     cards_db.update_balance(id, balance - buy_val)
     embed = discord.Embed(title=f"💰 Bought: **{card_info['name']}** 💰",
                           color=15834065)
     embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
     embed.description = f"Bought the card for {buy_val} Big Bucks."
     await ctx.send(embed=embed)