def __init__(self, item_data): self.name = item_data.get('name') self.desc = item_data.get('description') self.rarity = item_data.get('rarity') self.type = item_data.get('type') self.rarity_name = rarity_names.get(self.rarity) self.icon = item_icons.get(self.type.lower()).get(self.rarity) self.color = item_colors.get(self.type.lower()).get(self.rarity) self.value = prices.get(self.rarity) self.file_id = item_data.get('file_id')
async def hunt(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ item_core = await get_item_core(cmd.db) if not await cmd.bot.cool_down.on_cooldown(cmd.name, pld.msg.author): upgrade_file = await cmd.bot.db.get_profile(pld.msg.author.id, 'upgrades') or {} inv = await cmd.db.get_inventory(pld.msg.author.id) storage = upgrade_file.get('storage', 0) inv_limit = 64 + (8 * storage) if len(inv) < inv_limit: base_cooldown = 60 stamina = upgrade_file.get('stamina', 0) cooldown = int(base_cooldown - ((base_cooldown / 100) * ((stamina * 0.5) / (1.25 + (0.01 * stamina))))) cooldown = 5 if cooldown < 5 else cooldown await cmd.bot.cool_down.set_cooldown(cmd.name, pld.msg.author, cooldown) rarity = await item_core.roll_rarity(await cmd.bot.db.get_profile( pld.msg.author.id)) if pld.args: if pld.msg.author.id in cmd.bot.cfg.dsc.owners: try: if int(pld.args[0]) <= 9: rarity = int(pld.args[0]) except ValueError: pass if rarity == 0: response_title = '🗑 You hunted for a while but found nothing...' response = discord.Embed(color=0x67757f, title=response_title) else: item = item_core.pick_item_in_rarity('animal', rarity) connector = 'a' if item.rarity_name[0].lower() in ['a', 'e', 'i', 'o', 'u']: connector = 'an' try: success, timed_out = await item_dialogue( cmd.bot, pld.msg, item_icons.get(item.type.lower()), item) except (discord.NotFound, discord.Forbidden): success = timed_out = False if success: response_title = f'{item.icon} You caught {connector} {item.rarity_name} {item.name}!' data_for_inv = item.generate_inventory_item() await cmd.db.add_to_inventory(pld.msg.author.id, data_for_inv) await item_core.add_item_statistic(cmd.db, item, pld.msg.author) await cmd.db.add_resource(pld.msg.author.id, 'items', 1, cmd.name, pld.msg, True) response = discord.Embed(color=item.color, title=response_title) else: if timed_out: response_title = f'🕙 Oh no... The {item.rarity_name} {item.type.lower()} escaped...' response = discord.Embed(color=0x696969, title=response_title) else: response_title = '❌ Oh no... The feisty little thing slipped out of your grasp...' response = discord.Embed(color=0xBE1931, title=response_title) else: response = error('Your inventory is full.') else: timeout = await cmd.bot.cool_down.get_cooldown(cmd.name, pld.msg.author) response = discord.Embed( color=0x696969, title=f'🕙 You are resting for another {timeout} seconds.') response.set_author(name=pld.msg.author.display_name, icon_url=user_avatar(pld.msg.author)) await pld.msg.channel.send(embed=response)
async def forage(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ ongoing = Ongoing.is_ongoing('profession', pld.msg.author.id) if not ongoing: Ongoing.set_ongoing('profession', pld.msg.author.id) item_core = await get_item_core(cmd.db) if not await cmd.bot.cool_down.on_cooldown('profession', pld.msg.author): upgrade_file = await cmd.bot.db.get_profile( pld.msg.author.id, 'upgrades') or {} inv = await cmd.db.get_inventory(pld.msg.author.id) storage = upgrade_file.get('storage', 0) inv_limit = 64 + (8 * storage) if len(inv) < inv_limit: base_cooldown = 20 stamina = upgrade_file.get('stamina', 0) cooldown = int(base_cooldown - ((base_cooldown / 100) * ((stamina * 0.5) / (1.25 + (0.01 * stamina))))) cooldown = 2 if cooldown < 2 else cooldown await cmd.bot.cool_down.set_cooldown('profession', pld.msg.author, cooldown) rarity = await item_core.roll_rarity( await cmd.bot.db.get_profile(pld.msg.author.id)) if pld.args: if pld.msg.author.id in cmd.bot.cfg.dsc.owners: try: if int(pld.args[0]) <= 9: rarity = int(pld.args[0]) except ValueError: pass item = item_core.pick_item_in_rarity('plant', rarity) connector = 'a' if item.rarity_name[0].lower() in ['a', 'e', 'i', 'o', 'u']: connector = 'an' if rarity == 0: if item.name[0].lower() in ['a', 'e', 'i', 'o', 'u']: connector = 'an' response_title = f'{item.icon} You found {connector} {item.name} and threw it away!' response = discord.Embed(color=item.color, title=response_title) else: dialogue = DialogueCore(cmd.bot, pld.msg, None) dresp = await dialogue.item_dialogue( item_icons.get(item.type.lower()), item) if dresp.ok: response_title = f'{item.icon} You found {connector} {item.rarity_name} {item.name}!' data_for_inv = item.generate_inventory_item() await cmd.db.add_to_inventory(pld.msg.author.id, data_for_inv) await item_core.add_item_statistic( cmd.db, item, pld.msg.author) await cmd.db.add_resource(pld.msg.author.id, 'items', 1, cmd.name, pld.msg, True) await cmd.db.add_resource(pld.msg.author.id, 'plant', 1, cmd.name, pld.msg, True) response = discord.Embed(color=item.color, title=response_title) else: if dresp.timed_out: response_title = f'🕙 You forgot where the {item.rarity_name} {item.type.lower()} is...' response = discord.Embed(color=0x696969, title=response_title) elif dresp.cancelled: response_title = '❌ Oh no... You dug too hard and hurt the plant...' response = discord.Embed(color=0xBE1931, title=response_title) else: response = dresp.generic('foraging') else: response = GenericResponse('Your inventory is full.').error() else: timeout = await cmd.bot.cool_down.get_cooldown( 'profession', pld.msg.author) response = discord.Embed( color=0x696969, title=f'🕙 You are resting for another {timeout} seconds.') Ongoing.del_ongoing('profession', pld.msg.author.id) else: response = GenericResponse( "Can't do multiple professions at once.").warn() response.set_author(name=pld.msg.author.display_name, icon_url=user_avatar(pld.msg.author)) await pld.msg.channel.send(embed=response)