Beispiel #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)
Beispiel #2
0
 async def plant(ctx):
     db.check_user(ctx.message, conn)
     if not (db.check_player(ctx.message, conn)):
         async with ctx.message.channel.typing():
             await asyncio.sleep(3)
         await ctx.message.channel.send('Welcome new player!')
         async with ctx.message.channel.typing():
             await asyncio.sleep(3)
         await ctx.message.channel.send(
             'You currently have no coffee beans, but you\'ll get more soon!'
         )
         async with ctx.message.channel.typing():
             await asyncio.sleep(3)
     if (db.plant_beans(ctx.message, conn)):
         outputString = 'Your coffee tree have been planted! Please wait a while until it\'s ready to harvest.'
         plantEmbed = discord.Embed(title='Coffee has been Planted!',
                                    description=outputString,
                                    colour=conf.colourCoffee)
         await ctx.message.channel.send(embed=plantEmbed)
     else:
         outputString = 'You\'ve already planted a tree!'
         plantEmbed = discord.Embed(title='Coffee Already Planted!',
                                    description=outputString,
                                    colour=conf.colourCoffee)
         await ctx.message.channel.send(embed=plantEmbed)
Beispiel #3
0
 async def shop(ctx):
     db.check_user(ctx.message, conn)
     if not(db.check_player(ctx.message, conn)):
         await cf.introMessage(ctx.message)
     else:
         itemTrees = f'Trees : **$10** per tree.'
         itemLand = f'Land : **$5,000** per acre (space for 500 trees).'
         outputString = itemTrees + '\n' + itemLand
         shopEmbed = discord.Embed(title='Shop', description=outputString, colour=conf.colourCoffee)
         footerString = '$buy [item name] [amount]'
         shopEmbed.set_footer(text=footerString)
         await ctx.message.channel.send(embed=shopEmbed)
Beispiel #4
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)
Beispiel #5
0
 async def harvest(ctx):
     db.check_user(ctx.message, conn)
     if not (db.check_player(ctx.message, conn)):
         await introMessage(ctx.message)
     else:
         harvestedBeans = db.harvest_beans(ctx.message, conn)
         if (harvestedBeans >= 0):
             outputString = 'You harvested your coffee trees and got **' + f'{harvestedBeans:,}' + '** grams of green beans!'
             harvestEmbed = discord.Embed(title='Coffee Harvested!',
                                          description=outputString,
                                          colour=conf.colourCoffee)
             await ctx.message.channel.send(embed=harvestEmbed)
         else:
             outputString = 'You haven\'t ``$plant``ed any trees yet! .'
             harvestEmbed = discord.Embed(title='No Coffee to Harvest!',
                                          description=outputString,
                                          colour=conf.colourCoffee)
             await ctx.message.channel.send(embed=harvestEmbed)
Beispiel #6
0
 async def roast(ctx, *arg):
     try:
         db.check_user(ctx.message, conn)
         if (len(arg) == 1):
             bags = math.floor(int(arg[0]))
             if (bags < 1):
                 await ctx.message.channel.send(
                     'The amount of bags you specified isn\'t possible. Defaulting to **1**.'
                 )
                 bags = 1
         elif (len(arg) == 0):
             bags = 1
         else:
             await ctx.message.channel.send(
                 'Too many arguments. Use ``$roast`` or ``$roast [number]``'
             )
             return
         if not (db.check_player(ctx.message, conn)):
             await introMessage(ctx.message)
         else:
             currGreenBeans = db.get_beans(ctx.message, conn)
             if (currGreenBeans < (bags * 250)):
                 bags = math.floor(currGreenBeans / 250)
                 beansToRoast = 250 * bags
             else:
                 beansToRoast = 250 * bags
             if (beansToRoast < 250):
                 await ctx.message.channel.send(
                     'You currently only have **' + f'{beansToRoast:,}' +
                     '** grams of beans. You need at least 250 grams to make a bag.'
                 )
             else:
                 if db.roast_beans(ctx.message, beansToRoast, conn):
                     beans = db.get_beans(ctx.message, conn)
                     outputString = f'Done! You\'ve used **{beansToRoast:,}** beans to make **{bags:,}** bags. You have **{beans:,}** grams of green beans remaining.'
                     roastEmbed = discord.Embed(title='Beans Roasted!',
                                                description=outputString,
                                                colour=conf.colourCoffee)
                     await ctx.message.channel.send(embed=roastEmbed)
                 else:
                     await ctx.message.channel.send('Something went wrong.')
     except ValueError:
         await ctx.message.channel.send(
             'Please use a number. Example : ``$roast 2``')