Example #1
0
    async def status(ctx):
        db.check_user(ctx.message, conn)
        if not (db.check_player(ctx.message, conn)):
            await introMessage(ctx.message)
        else:
            userAvatar = ctx.author.avatar_url
            bags = db.get_bags(ctx.message, conn)
            beans = db.get_beans(ctx.message, conn)
            money = db.get_money(ctx.message, conn)
            trees = db.get_trees(ctx.message, conn)
            land = db.get_land(ctx.message, conn)
            outputString = f'**Money** : ${money:,.2f}' + '\n=====================\n' + f'**Green Beans** : {beans:,} grams.' + '\n' + f'**Bags** : {bags:,} bags.' + '\n' + f'**Trees** : {trees:,} trees.' + '\n' + f'**Land** : {land:,} acres.'

            statusEmbed = discord.Embed(title=ctx.author.display_name,
                                        description=outputString,
                                        colour=conf.colourCoffee)
            # Alternate
            """
            statusEmbed.add_field(name='Green Beans', value=f'{beans:,} grams.', inline=True)
            statusEmbed.add_field(name='Bags', value=f'{bags:,} bags.', inline=True)
            statusEmbed.add_field(name='Trees', value=f'{trees:,} trees.', inline=False)
            statusEmbed.add_field(name='Land', value=f'{land:,} acres.', inline=True)
            statusEmbed.add_field(name='Money', value=f'${money:,.2f}', inline=False)
            """
            statusEmbed.set_thumbnail(url=userAvatar)
            await ctx.message.channel.send(embed=statusEmbed)
Example #2
0
 async def buy(ctx, item: str, amount: int):
     if(amount >= 0):
         db.check_user(ctx.message, conn)
         item = item.lower()
         currentMoney = db.get_money(ctx.message, conn)
         if not(db.check_player(ctx.message, conn)):
             cf.introMessage(ctx.message)
         else:
             if item == 'trees':
                 availableAcres = db.get_land(ctx.message, conn)
                 currentTrees = db.get_trees(ctx.message, conn)
                 maxTreesLimit = conf.treesLimit * availableAcres
                 # Check if trees have been planted
                 if db.get_plant_status(ctx.message, conn) is True:
                     outputString = f'You currently have not harvested your trees yet! You\'re allowed to buy more trees after you\'ve harvested your coffee beans.'
                     buyEmbed = discord.Embed(title='Shop - Unharvested Crops', description=outputString, colour=conf.colourCoffee)
                     await ctx.message.channel.send(embed=buyEmbed)
                 # Check if the amount of trees you're buying are exceeding the limit
                 elif (currentTrees + amount) > maxTreesLimit:
                     outputString = f'You have no more room for more trees! Currently you only have **{(maxTreesLimit - currentTrees):,}** trees worth of free space. Buy more land to plant more trees!'
                     buyEmbed = discord.Embed(title='Shop - Insufficient Room', description=outputString, colour=conf.colourCoffee)
                     await ctx.message.channel.send(embed=buyEmbed)
                 # Check if the player has enough money to purchase the trees
                 elif currentMoney < (amount * conf.treePrice):
                     outputString = f'You currently have **${currentMoney:,.2f}** and tried to buy **${(amount*conf.treePrice):,.2f}** worth of {item}. Sell bags of coffee to get more money!'
                     buyEmbed = discord.Embed(title='Shop - Insufficient Funds', description=outputString, colour=conf.colourCoffee)
                     await ctx.message.channel.send(embed=buyEmbed)
                 else:
                     db.buy_trees(ctx.message, amount, conn)
                     outputString = f'You\'ve bought {amount:,} {item}!'
                     buyEmbed = discord.Embed(title='Shop - Purchase Successful!', description=outputString, colour=conf.colourCoffee)
                     await ctx.message.channel.send(embed=buyEmbed)
             if item == 'land':
                 # Check if the player has enough money to buy the land
                 if currentMoney < (amount * conf.landPrice):
                     # Purchase fail
                     outputString = f'You currently have **${currentMoney:,.2f}** and tried to buy **${(amount*conf.landPrice):,.2f}** worth of {item}. Sell bags of coffee to get more money!'
                     buyEmbed = discord.Embed(title='Shop - Insufficient Funds', description=outputString, colour=conf.colourCoffee)
                     await ctx.message.channel.send(embed=buyEmbed)
                 else:
                     # Purchase successful
                     db.buy_land(ctx.message, amount, conn)
                     outputString = f'You\'ve bought {amount:,} {item}!'
                     buyEmbed = discord.Embed(title='Shop - Purchase Successful!', description=outputString, colour=conf.colourCoffee)
                     await ctx.message.channel.send(embed=buyEmbed)
     else:
         outputString = f'Invalid amount.'
         buyEmbed = discord.Embed(title='Shop - Error', description=outputString, colour=conf.colourCoffee)
         await ctx.message.channel.send(embed=buyEmbed)