async def chances(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 pld.msg.mentions:
        target = pld.msg.mentions[0]
    else:
        target = pld.msg.author
    upgrade_level = None
    if pld.args:
        if pld.msg.author.id in cmd.bot.cfg.dsc.owners:
            if len(pld.args) > 1:
                if pld.args[-1].isdigit:
                    upgrade_level = int(pld.args[-1])
    if upgrade_level is None:
        upgrade_file = await cmd.db.get_profile(target.id, 'upgrades') or {}
        upgrade_level = upgrade_file.get('luck') or 0
    top_roll, rarities = item_core.create_roll_range(upgrade_level)
    out_lines = []
    table_head = ['Rarity', 'Chance']
    for rarity_key in rarities.keys():
        if rarity_key != 0:
            new_key = rarity_key - 1
            range_top = rarities.get(rarity_key) - rarities.get(new_key)
            chance = round((range_top / top_roll) * 100, 5)
            out_line = [rarity_names.get(new_key).title(), f'{chance}%']
            out_lines.append(out_line)
    range_top = top_roll - rarities.get(9)
    chance = round((range_top / top_roll) * 100, 5)
    out_line = [rarity_names.get(9).title(), f'{chance}%']
    out_lines.append(out_line)
    out_table = boop(out_lines, table_head)
    response = discord.Embed(color=0x1b6f5f)
    response.set_author(name=f'{target.name}\'s Item Chances',
                        icon_url=user_avatar(target))
    response.add_field(name='Luck',
                       value=f'Your Luck is Level {upgrade_level}',
                       inline=False)
    response.add_field(name='Chances Table',
                       value=f'```bat\n{out_table}\n```',
                       inline=False)
    await pld.msg.channel.send(embed=response)
Beispiel #2
0
 def __init__(self, item_data):
     self.name = item_data.get('name')
     self.desc = item_data.get('description')
     self.type = item_data.get('type')
     self.icon = cook_icons.get(self.type.lower())
     self.color = cook_colors.get(self.type.lower())
     self.value = 0
     self.file_id = item_data.get('file_id')
     self.rarity = 11
     self.rarity_name = rarity_names.get(self.rarity)
Beispiel #3
0
 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')
Beispiel #4
0
async def chances(cmd: SigmaCommand, message: discord.Message, args: list):
    item_core = await get_item_core(cmd.db)
    if message.mentions:
        target = message.mentions[0]
    else:
        target = message.author
    upgrade_level = None
    if args:
        if message.author.id in cmd.bot.cfg.dsc.owners:
            if args[-1].isdigit:
                upgrade_level = int(args[-1])
    if upgrade_level is None:
        upgrade_file = await cmd.db[cmd.db.db_nam].Upgrades.find_one(
            {'UserID': target.id}) or {}
        upgrade_level = upgrade_file.get('luck') or 0
    top_roll, rarities = item_core.create_roll_range(upgrade_level)
    out_lines = []
    table_head = ['Rarity', 'Chance']
    for rarity_key in rarities.keys():
        if rarity_key != 0:
            new_key = rarity_key - 1
            range_top = rarities.get(rarity_key) - rarities.get(new_key)
            chance = round((range_top / top_roll) * 100, 5)
            out_line = [rarity_names.get(new_key).title(), f'{chance}%']
            out_lines.append(out_line)
    range_top = top_roll - rarities.get(9)
    chance = round((range_top / top_roll) * 100, 5)
    out_line = [rarity_names.get(9).title(), f'{chance}%']
    out_lines.append(out_line)
    out_table = boop(out_lines, table_head)
    response = discord.Embed(color=0x1b6f5f)
    response.set_author(name=f'{target.name}\'s Item Chances',
                        icon_url=user_avatar(target))
    response.add_field(name='Luck',
                       value=f'Your Luck is Level {upgrade_level}',
                       inline=False)
    response.add_field(name=f'Chances Table',
                       value=f'```bat\n{out_table}\n```',
                       inline=False)
    await message.channel.send(embed=response)