async def _buy_item(self, ctx, item_id: int = 0, count: int = 0): """Buy an item from the store.""" item_object = Item(item_id) cost = item_object.get_price() * count player = Player(ctx.message.author.id) balance = player.get_balance() wallet = balance['wallet'] if cost > wallet: return await ctx.send("Not enough cash. Need: " + str(cost)) else: player.add_balance('wallet', -cost) player.add_to_inventory(item_id, count) return await ctx.send("Successfully purchased.")
async def _get_profile(self, ctx): """See your player profile, balances, current location and inventory.""" player = Player(ctx.message.author.id) inventory_list = player.get_inventory() balances = player.get_balance() location = Location(player.current_location) stores = self.stores.at_location(player.current_location) stores_str = '' for store in stores: if store.location.location_id == player.current_location: if store != stores[-1]: stores_str = stores_str + store.name + ', ' else: stores_str = stores_str + store.name embed = discord.Embed(title='Profile', description='Current Location: ' + location.name, colour=discord.Colour.gold()) if stores_str != '': embed.add_field(name='Stores:', value=stores_str, inline=False) inventory_str = '' if len(inventory_list) > 0: for inventory in inventory_list: item_object = Item(inventory['id']) inventory_str = inventory_str + item_object.emoji + '(' + str( inventory['count']) + ') ' + ' ' + item_object.name + '\n' else: inventory_str = 'Empty Inventory' embed.add_field(name='Bank Balance:', value=':moneybag:' + '{:20,.0f}'.format(balances['bank'])) embed.add_field(name='Cash Balance:', value=':moneybag:' + '{:20,.0f}'.format(balances['wallet'])) embed.add_field(name='Inventory', value=inventory_str, inline=False) embed.set_author(name=ctx.message.author.display_name, icon_url=ctx.message.author.avatar_url) embed.set_thumbnail(url=ctx.message.author.avatar_url) return await ctx.send(embed=embed)