import re from helpers import * from db_calls import * import discord from discord.ext import commands, tasks from discord import app_commands from discord.app_commands import Choice import random class Dice(commands.Cog): def __init__(self, bot): self.bot = bot self.rolls = [] self.current = None self.updates.start() async def cog_command_error(self, ctx, error): await ctx.send(f'{error}') async def get_dice_embed(self, channel, title, message): try: team_abbrev = re.split('-', channel.name) if len(team_abbrev[0]) <= 4 and team_abbrev not in ['the', 'city']: team = await get_one_team(team_abbrev[0], timeout=1) else: team = None except (ValueError, AttributeError, requests.ReadTimeout) as e: logging.info(f'{type(e)}: {e}') team = None if team: embed = discord.Embed( color=int(team["dice_color"], 16) if team["dice_color"] else int(team["color"], 16) ) else: embed = discord.Embed( color=int('0x000000', 16) ) if title and message: embed.add_field(name=title, value=message) return embed @tasks.loop(minutes=5) async def updates(self): self.current = await get_current() if len(self.rolls) > 0: all_rolls = self.rolls self.rolls = [] await post_dice(all_rolls) @commands.command(name='ab', aliases=['atbat', 'swing', 'pa'], help='ab, atbat, or swing') async def ab_roll(self, ctx): """ Make an AB roll including potential pitcher injuries. """ team = None d_twenty = random.randint(1, 20) d_twenty_two = random.randint(1, 20) flag = None if d_twenty == 1: flag = 'wild pitch' elif d_twenty == 2: if random.randint(1, 2) == 1: flag = 'balk' else: flag = 'passed ball' if flag: roll_message = f'```md\nCheck {flag}```\n' \ f'{flag.title()} roll```md\n# {d_twenty_two}\nDetails: [1d20 ({d_twenty_two})]```\n' embed = await self.get_dice_embed(ctx.channel, f'Chaos roll for {ctx.author.name}', roll_message) embed.set_footer( text='If there are no baserunners, ignore this chaos. If the chaos roll failed, ignore future chaos ' 'until a new batter comes to the plate.' ) await ctx.channel.send( content=None, embed=embed ) return d_six_one = random.randint(1, 6) d_six_two = random.randint(1, 6) d_six_three = random.randint(1, 6) d_twenty = random.randint(1, 20) roll_message = f'```md\n# {d_six_one},{d_six_two + d_six_three},'\ f'{d_twenty}\nDetails:[1d6;2d6;1d20 ({d_six_one} - {d_six_two} {d_six_three} - '\ f'{d_twenty})]```' if d_six_one == 6 and d_six_two + d_six_three > 6: roll_message += f'\n**Check injury for pitcher injury rating {13 - d_six_two - d_six_three}**\n' \ f'Oops! All injuries!' logging.info(f'roll_message: {roll_message}') await ctx.channel.send( content=None, embed=await self.get_dice_embed(ctx.channel, f'At bat roll for {ctx.author.name}', roll_message) ) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'dsix': d_six_one, 'twodsix': d_six_two + d_six_three, 'dtwenty': d_twenty } self.rolls.append(this_roll) @commands.command(name='1d20', aliases=['d20'], help='1d20 or d20') async def dtwenty_roll(self, ctx): """ Roll a single d20. """ team = None d_twenty = random.randint(1, 20) roll_message = f'```md\n# {str(d_twenty)}\n'\ f'Details:[1d20 ({d_twenty})]```' await ctx.channel.send( content=None, embed=await self.get_dice_embed(ctx.channel, f'd20 roll for {ctx.author.name}', roll_message) ) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'dtwenty': d_twenty } self.rolls.append(this_roll) @commands.command(name='af', aliases=['fielding'], help='Advanced fielding') async def fielding_roll(self, ctx, *args): """ Make an Advanced fielding check. """ team = None d_six_one = random.randint(1, 6) d_six_two = random.randint(1, 6) d_six_three = random.randint(1, 6) d_twenty = random.randint(1, 20) image = None if args: if args[0][:2].upper() == '1B': image = 'https://media.discordapp.net/attachments/643871298023325718/688021155595944081/1b.PNG' elif args[0][:2].upper() == '2B': image = 'https://media.discordapp.net/attachments/643871298023325718/688021157496356900/2b.PNG' elif args[0][:2].upper() == '3B': image = 'https://media.discordapp.net/attachments/643871298023325718/688021159115096106/3b.PNG' elif args[0][:2].upper() == 'SS': image = 'https://media.discordapp.net/attachments/643871298023325718/688021167486795809/ss.PNG' elif args[0][:2].upper() == 'LF' or args[0][:2].upper() == 'RF': image = 'https://media.discordapp.net/attachments/643871298023325718/688021163711922216/lf.PNG' elif args[0][:2].upper() == 'CF': image = 'https://media.discordapp.net/attachments/643871298023325718/688021162172612638/cf.PNG' elif args[0][0].upper() == 'C': image = 'https://media.discordapp.net/attachments/643871298023325718/688021160603942948/c.PNG' elif args[0][0].upper() == 'P': image = 'https://media.discordapp.net/attachments/643871298023325718/688021165746552872/p.PNG' roll_message = f'```md\n# '\ f'{d_twenty},{d_six_two + d_six_three},{d_six_one}\n'\ f'Details:[1d20;2d6;1d6 ({d_twenty} - {d_six_two} {d_six_three} - '\ f'{d_six_one})]```' if image: embed = discord.Embed(title=f'Fielding Chart') embed.set_image(url=image) await ctx.send(content=roll_message, embed=embed) else: await ctx.channel.send( content=None, embed=await self.get_dice_embed(ctx.channel, f'Fielding roll for {ctx.author.name}', roll_message) ) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'dsix': d_six_one, 'twodsix': d_six_two + d_six_three, 'dtwenty': d_twenty } self.rolls.append(this_roll) @commands.command(name='i', aliases=['injury'], help='i or injury') async def injury_roll(self, ctx): """ Make an injury check. """ team = None d_twenty = random.randint(1, 20) roll_message = f'Injury roll for {ctx.author.name}\n```md\n# {d_twenty}\n'\ f'Details:[1d20 ({d_twenty})]```' embed = discord.Embed(title='Injury Chart', description='See https://sombaseball.ddns.net/rules#injuries') embed.set_image(url='https://sombaseball.ddns.net/static/images/season04/injury-chart.png') await ctx.channel.send(content=roll_message, embed=embed) if d_twenty > 8: await ctx.send(random_salute_gif()) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'dtwenty': d_twenty } self.rolls.append(this_roll) @app_commands.command(name='injury', description='Make an injury check; rating = left of "p", games = right') @app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID'))) @app_commands.choices(games=[ Choice(name='86', value=86), Choice(name='80', value=80), Choice(name='70', value=70), Choice(name='60', value=60), Choice(name='50', value=50), Choice(name='40', value=40), Choice(name='30', value=30), Choice(name='20', value=20), ], rating=[ Choice(name='1', value=1), Choice(name='2', value=2), Choice(name='3', value=3), Choice(name='4', value=4), Choice(name='5', value=5), Choice(name='6', value=6), ]) async def injury_roll_slash(self, interaction: discord.Interaction, rating: Choice[int], games: Choice[int]): team = None d_six_one = random.randint(1, 6) d_six_two = random.randint(1, 6) d_six_three = random.randint(1, 6) injury_roll = d_six_one + d_six_two + d_six_three inj_data = { 'one': { 'p86': ['OK', 'OK', 'OK', 'OK', 'OK', 'OK', 'REM', 'REM', 1, 1, 2, 2, 3, 3, 4, 5], 'p80': [2, 2, 'OK', 'REM', 1, 2, 3, 3, 4, 4, 5, 5, 6, 8, 12, 16], 'p70': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 5, 6, 6, 8, 12, 16, 20, 20], 'p60': ['OK', 'REM', 1, 2, 3, 4, 5, 6, 6, 8, 12, 12, 16, 20, 20, 'OK'], 'p50': ['OK', 1, 2, 3, 4, 5, 6, 8, 8, 12, 12, 16, 20, 30, 'REM', 'OK'], 'p40': ['OK', 5, 1, 3, 5, 6, 8, 12, 12, 16, 20, 30, 4, 2, 'REM', 'OK'], 'p30': ['OK', 1, 2, 5, 6, 8, 12, 16, 20, 30, 12, 8, 4, 3, 'REM', 'OK'], 'p20': ['OK', 1, 2, 5, 6, 12, 12, 30, 20, 16, 16, 8, 4, 3, 'REM', 'OK'] }, 'two': { 'p86': [4, 3, 2, 2, 1, 1, 'REM', 'OK', 'REM', 'OK', 2, 1, 2, 2, 3, 5], 'p80': [12, 6, 4, 2, 2, 'OK', 1, 'OK', 'REM', 1, 'REM', 2, 3, 5, 8, 16], 'p70': [1, 3, 4, 6, 2, 2, 'OK', 1, 3, 'REM', 4, 5, 8, 12, 16, 3], 'p60': [5, 'OK', 'OK', 'REM', 1, 2, 5, 3, 4, 6, 4, 8, 12, 16, 16, 'OK'], 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 5, 8, 12, 16, 20, 20, 'OK'], 'p40': ['OK', 'REM', 1, 2, 3, 4, 5, 6, 8, 6, 12, 16, 20, 30, 'REM', 'OK'], 'p30': ['OK', 1, 2, 4, 5, 6, 8, 6, 12, 16, 8, 20, 30, 3, 5, 'REM'], 'p20': ['OK', 1, 4, 5, 6, 6, 8, 8, 16, 12, 20, 30, 12, 3, 2, 'REM'] }, 'three': { 'p86': [], 'p80': ['OK', 'OK', 'REM', 1, 3, 'OK', 'REM', 1, 2, 1, 2, 3, 4, 5, 6, 'REM'], 'p70': ['OK', 6, 'OK', 'REM', 1, 2, 2, 3, 4, 5, 1, 3, 6, 8, 12, 'REM'], 'p60': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 4, 5, 8, 12, 12, 16, 'REM'], 'p50': ['OK', 1, 1, 2, 3, 4, 5, 6, 8, 6, 8, 12, 12, 16, 5, 'REM'], 'p40': ['OK', 1, 2, 3, 4, 6, 5, 8, 6, 8, 12, 12, 16, 20, 1, 'REM'], 'p30': ['OK', 2, 3, 4, 5, 8, 6, 8, 12, 12, 16, 6, 20, 30, 1, 'REM'], 'p20': ['OK', 1, 2, 4, 5, 12, 12, 8, 6, 16, 8, 20, 30, 3, 5, 'REM'] }, 'four': { 'p86': [], 'p80': [], 'p70': ['OK', 'OK', 'REM', 3, 3, 'OK', 'REM', 1, 2, 1, 4, 5, 6, 8, 12, 'REM'], 'p60': ['OK', 8, 4, 'OK', 'REM', 1, 2, 4, 5, 3, 6, 3, 8, 12, 16, 'REM'], 'p50': ['OK', 'OK', 'REM', 1, 2, 3, 4, 5, 6, 4, 5, 8, 12, 12, 16, 'REM'], 'p40': ['OK', 1, 1, 2, 3, 4, 5, 6, 8, 6, 8, 12, 12, 16, 5, 'REM'], 'p30': ['OK', 'REM', 2, 3, 4, 5, 6, 6, 8, 8, 16, 12, 12, 1, 20, 'REM'], 'p20': ['OK', 1, 2, 3, 4, 6, 5, 8, 6, 8, 16, 12, 12, 20, 1, 'REM'] }, 'five': { 'p86': [], 'p80': [], 'p70': [], 'p60': ['OK', 'OK', 'REM', 1, 1, 'OK', 'REM', 3, 2, 4, 5, 6, 8, 6, 12, 16], 'p50': ['OK', 8, 8, 'OK', 1, 3, 2, 4, 5, 6, 'REM', 3, 12, 8, 16, 1], 'p40': ['OK', 'OK', 'REM', 5, 1, 2, 6, 4, 8, 3, 5, 12, 6, 8, 16, 'REM'], 'p30': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 3, 1, 16, 'REM'], 'p20': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 12, 1, 16, 'REM'] }, 'six': { 'p86': [], 'p80': [], 'p70': [], 'p60': [], 'p50': ['OK', 8, 3, 'OK', 1, 3, 2, 4, 5, 6, 'REM', 8, 12, 3, 16, 1], 'p40': ['OK', 'OK', 'REM', 5, 1, 3, 8, 4, 6, 2, 5, 12, 3, 4, 16, 'REM'], 'p30': ['OK', 'REM', 4, 5, 2, 3, 6, 4, 8, 5, 12, 6, 3, 1, 16, 'REM'], 'p20': ['OK', 'REM', 2, 3, 5, 4, 6, 5, 8, 6, 12, 8, 12, 1, 16, 'REM'] } } p_ratings = ['one', 'two', 'three', 'four', 'five', 'six'] injury_string = f'```md\n# {injury_roll}\n' \ f'Details:[3d6 ({d_six_one} {d_six_two} {d_six_three})]\n```\n' logging.info(f'injury rating: {rating.value}p{games.value}') injury_list = inj_data[p_ratings[rating.value - 1]][f'p{games.value}'] injury_result = injury_list[injury_roll - 3] logging.info(f'injury rating: {rating.value}p{games.value} / array: {injury_list}[{injury_roll - 2}] / result: {injury_result}') if isinstance(injury_result, int): await interaction.response.send_message(random_salute_gif()) injury_string += f'With a roll of {injury_roll}, the injury length is **{injury_result} ' \ f'game{"s" if injury_result > 1 else ""}**.' elif injury_result == 'REM': await interaction.response.send_message(random_salute_gif()) injury_string += f'With a roll of {injury_roll}, the injury length is **REMAINDER OF GAME** for batters ' \ f'or **FATIGUED** for pitchers' else: await interaction.response.send_message(random_conf_gif()) injury_string += f'With a roll of {injury_roll}, the player is **OKAY** - no injury!' embed = await self.get_dice_embed( interaction.channel.name, f'Injury roll for {interaction.user.name}', injury_string ) embed.set_footer(text='For pitchers, add their current rest to the injury') await interaction.channel.send(content=None, embed=embed) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': interaction.user.id, 'threedsix': d_six_one + d_six_two + d_six_three } self.rolls.append(this_roll) @commands.command(name='c', aliases=['chaos', 'choas'], help='c, chaos, or choas') async def chaos_roll(self, ctx): """ Have the pitcher check for chaos with a runner on base. """ await react_and_reply( ctx, '❌', 'This command has been deprecated. It is now implemented within the `!ab` command. If you need manual ' 'chaos, use the Paper Dynasty bot.' ) return d_twenty = random.randint(1, 20) d_twenty_two = random.randint(1, 20) flag = None if d_twenty == 1: flag = 'wild pitch' elif d_twenty == 2: if random.randint(1, 2) == 1: flag = 'balk' else: flag = 'passed ball' if not flag: roll_message = f'Chaos roll for {ctx.author.name}\n```md\nNo Chaos```' else: roll_message = f'Chaos roll for {ctx.author.name}\n```md\nCheck {flag}```\n'\ f'{flag.title()} roll```md\n# {d_twenty_two}\nDetails: [1d20 ({d_twenty_two})]```' await ctx.channel.send(roll_message) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'dtwenty': d_twenty } self.rolls.append(this_roll) @commands.command(name='j', aliases=['jump'], help='j or jump') async def jump_roll(self, ctx): """ Check for a baserunner's jump before stealing. """ team = None d_six_one = random.randint(1, 6) d_six_two = random.randint(1, 6) d_twenty = random.randint(1, 20) d_twenty_two = random.randint(1, 20) flag = None if d_twenty == 1: flag = 'pickoff' elif d_twenty == 2: flag = 'balk' if not flag: roll_message = f'```md\n# {d_six_one + d_six_two}\n'\ f'Details:[2d6 ({d_six_one} {d_six_two})]```' else: roll_message = f'```md\nCheck {flag}```\n' \ f'{flag.title()} roll```md\n# {d_twenty_two}\nDetails: [1d20 ({d_twenty_two})]```' await ctx.channel.send( content=None, embed=await self.get_dice_embed(ctx.channel, f'Jump roll for {ctx.author.name}', roll_message) ) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'twodsix': d_six_two + d_six_one, 'dtwenty': d_twenty } self.rolls.append(this_roll) @commands.command(name='f', aliases=['safielding', 'saf'], help='f or safielding') async def sa_fielding_roll(self, ctx, *args): """ Make a Super Advanced fielding check. """ team = None d_twenty = random.randint(1, 20) d_six_one = random.randint(1, 6) d_six_two = random.randint(1, 6) d_six_three = random.randint(1, 6) error_dice = d_six_one + d_six_two + d_six_three x_chart = None error_chart = 'https://sombaseball.ddns.net/static/images/season04/error-' range_note = None error_note = None error_note1 = None error_note2 = None symbol_link = 'https://docs.google.com/document/d/1wu63XSgfQE2wadiegWaaDda11QvqkN0liRurKm0vcTs/edit' \ '#heading=h.7oj0v3t1kc6o' if args: if args[0][:2].upper() == '1B' or args[0][:2].upper() == '2B' or args[0][:2].upper() == '3B' \ or args[0][:2].upper() == 'SS': x_chart = 'https://sombaseball.ddns.net/static/images/season04/range-infield.png' # Build range note if d_twenty == 1: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G3# SI1 ----SI2----\n' \ '```\n\n' elif d_twenty == 2: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G2# SI1 ----SI2----\n' \ '```\n\n' elif d_twenty <= 4: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G2# G3# SI1 --SI2--\n' \ '```\n\n' elif d_twenty == 5: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G1 --G3#-- SI1 SI2\n' \ '```\n\n' elif d_twenty == 6: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G1 G2# G3# SI1 SI2\n' \ '```\n\n' elif d_twenty <= 8: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G1 G2 --G3#-- SI1\n' \ '```\n\n' elif d_twenty == 9: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G1 G2 G3 --G3#--\n' \ '```\n\n' elif d_twenty == 10: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G1--- G2 --G3#--\n' \ '```\n\n' elif d_twenty <= 12: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G1--- G2 G3 G3#\n' \ '```\n\n' elif d_twenty == 13: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G1--- G2 --G3---\n' \ '```\n\n' elif d_twenty == 14: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G1--- --G2--- G3\n' \ '```\n\n' elif d_twenty <= 16: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '----G1----- G2 G3\n' \ '```\n\n' elif d_twenty == 17: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '------G1------- G3\n' \ '```\n\n' elif d_twenty <= 19: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '------G1------- G2\n' \ '```\n\n' elif d_twenty == 20: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--------G1---------\n' \ '```\n\n' if args[0][:2].upper() == '1B': error_chart += 'first-base.png' if error_dice == 18: error_note = '2-base error for e3 -> e12, e19 -> e28\n' \ '1-base error for e1, e2, e30' elif error_dice == 17: error_note = '2-base error for e13 -> e28\n' \ '1-base error for e1, e5, e8, e9, e29' elif error_dice == 16: error_note = '2-base error for e29, e30\n' \ '1-base error for e2, e8, e16, e19, e23' elif error_dice == 15: error_note = '1-base error for e3, e8, e10 -> e12, e20, e26, e30' elif error_dice == 14: error_note = '1-base error for e4, e5, e9, e15, e18, e22, e24 -> e28' elif error_dice == 13: error_note = '1-base error for e6, e13, e24, e26 -> e28, e30' elif error_dice == 12: error_note = '1-base error for e14 -> e18, e21 -> e26, e28 -> e30' elif error_dice == 11: error_note = '1-base error for e10, e13, e16 -> e20, e23 -> e25, e27 -> e30' elif error_dice == 10: error_note = '1-base error for e19 -> e21, e23, e29' elif error_dice == 9: error_note = '1-base error for e7, e12, e14, e21, e25, e26, e29' elif error_dice == 8: error_note = '1-base error for e11, e27' elif error_dice == 7: error_note = '1-base error for e9, e15, e22, e27, e28' elif error_dice == 6: error_note = '1-base error for e8, e11, e12, e17, e20' elif error_dice == 5: error_note = f'Rare play!\n\n' \ f'**G3**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**G2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**G1**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**SI1**: {INFIELD_X_CHART["si1"]["rp"]}\n' \ f'**SI2**: {OUTFIELD_X_CHART["si2"]["rp"]}\n' elif error_dice == 4: error_note = 'No error' elif error_dice == 3: error_note = '2-base error for e8 -> e12, e24 -> e28\n' \ '1-base error for e2, e3, e6, e7, e14, e16, e17, e21' if args[0][:2].upper() == '2B': error_chart += 'second-base.png' if error_dice == 18: error_note = '2-base error for e4 -> e19, e28 -> e41, e53 -> e65\n' \ '1-base error for e22, e24, e25, e27, e44, e50' elif error_dice == 17: error_note = '2-base error for e20 -> e41, e68, e71\n' \ '1-base error for e3, e4, e8 -> e12, e15, e16, e19' elif error_dice == 16: error_note = '2-base error for e53 -> 71\n' \ '1-base error for e5 -> 10, e14, e16, e29, e37' elif error_dice == 15: error_note = '1-base error for e11, e12, e14, e16, e17, e19, e26 -> e28, e30, e32, e37, ' \ 'e50 -> e62, e71' elif error_dice == 14: error_note = '1-base error for e13, e15, e34, e47, e65' elif error_dice == 13: error_note = '1-base error for e18, e20, e21, e26 -> e28, e39, e41, e50, e56, e59, e65, e71' elif error_dice == 12: error_note = '1-base error for e22, e30, e34, e39, e44, e47, e53, e56, e62, e68, e71' elif error_dice == 11: error_note = '1-base error for e23 -> e25, e29, e32, e37, e41, e50, e53, e59, e62, e68' elif error_dice == 10: error_note = '1-base error for e68' elif error_dice == 9: error_note = '1-base error for e44' elif error_dice == 8: error_note = 'No error' elif error_dice == 7: error_note = '1-base error for e47, e65' elif error_dice == 6: error_note = '1-base error for e17, e19, e56 -> 62' elif error_dice == 5: error_note = f'Rare play!\n\n' \ f'**G3**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**G2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**G1**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**SI1**: {INFIELD_X_CHART["si1"]["rp"]}\n' \ f'**SI2**: {OUTFIELD_X_CHART["si2"]["rp"]}\n' elif error_dice == 4: error_note = '1-base error for e10, e21' elif error_dice == 3: error_note = '2-base error for e12 -> e19, e37 -> e41, e59 -> e65\n' \ '1-base error for e2 -> e4, e6, e20, e25, e28, e29' if args[0][:2].upper() == '3B': error_chart += 'third-base.png' if error_dice == 18: error_note = '2-base error for e1, e2, e8, e10, e13 -> e16, e21 -> e24, e27, e30 -> e33, e50, ' \ 'e56, e62, e65\n' \ '1-base error for e39' elif error_dice == 17: error_note = '2-base error for e3 -> e10, e17, e18, e25 -> e27, e34 -> e37, e44, e47\n' \ '1-base error for e11, e19, e32, e56' elif error_dice == 16: error_note = '2-base error for e11 -> e18, e32, e33, e37, e53, e62, e65\n' \ '1-base error for e4, e8, e19, e21, e22, e27, e41' elif error_dice == 15: error_note = '2-base error for e19 -> 27, e32, e33, e37, e39, e44, e50, e59\n' \ '1-base error for e5 -> e8, e11, e14, e15, e17, e18, e28 -> e31, e34' elif error_dice == 14: error_note = '2-base error for e28 -> e31, e34, e35, e50\n' \ '1-base error for e14, e16, e19, e20, e22, e32, e39, e44, e56, e62' elif error_dice == 13: error_note = '2-base error for e41, e47, e53, e59\n' \ '1-base error for e10, e15, e23, e25, e28, e30, e32, e33, e35, e44, e65' elif error_dice == 12: error_note = '2-base error for e62\n' \ '1-base error for e12, e17, e22, e24, e27, e29, e34 -> e50, e56 -> e59, e65' elif error_dice == 11: error_note = '2-base error for e56, e65\n' \ '1-base error for e13, e18, e20, e21, e23, e26, e28, e31 -> e33, e35, e37, ' \ 'e41 -> e53, e59, e65' elif error_dice == 10: error_note = '1-base error for e26, e31, e41, e53 -> 65' elif error_dice == 9: error_note = '1-base error for e24, e27, e29, e34, e37, e39, e47 -> e65' elif error_dice == 8: error_note = '1-base error for e25, e30, e33, e47, e53, e56, e62, e65' elif error_dice == 7: error_note = '1-base error for e16, e19, e39, e59 -> e65' elif error_dice == 6: error_note = '1-base error for e21, e25, e30, e34, e53' elif error_dice == 5: error_note = f'Rare play!\n\n' \ f'**G3**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**G2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**G1**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**SI1**: {INFIELD_X_CHART["si1"]["rp"]}\n' \ f'**SI2**: {OUTFIELD_X_CHART["si2"]["rp"]}\n' elif error_dice == 4: error_note = '1-base error for e2, e3, e6, e14, e16, e44' elif error_dice == 3: error_note = '2-base error for e10, e15, e16, e23, e24, e56\n' \ '1-base error for e1 -> e4, e8, e14' if args[0][:2].upper() == 'SS': error_chart += 'shortstop.png' if error_dice == 18: error_note = '2-base error for e4 -> e12, e22 -> e32, e40 -> e48, e64, e68\n' \ '1-base error for e1, e18, e34, e52, e56' elif error_dice == 17: error_note = '2-base error for e14 -> 32, e52, e56, e72 -> e84\n' \ '1-base error for e3 -> e5, e8 ,e10, e36' elif error_dice == 16: error_note = '2-base error for e33 -> 56, e72\n' \ '1-base error for e6 -> e10, e17, e18, e20, e28, e31, e88' elif error_dice == 15: error_note = '2-base error for e60 -> e68, e76 -> 84\n' \ '1-base error for e12, e14, e17, e18, e20 -> e22, e24, e28, e31 -> 36, e40, ' \ 'e48, e72' elif error_dice == 14: error_note = '1-base error for e16, e19, e38, e42, e60, e68' elif error_dice == 13: error_note = '1-base error for e23, e25, e32 -> 38, e44, e52, e72 -> 84' elif error_dice == 12: error_note = '1-base error for e26, e27, e30, e42, e48, e56, e64, e68, e76 -> e88' elif error_dice == 11: error_note = '1-base error for e29, e40, e52 -> e60, e72, e80 -> e88' elif error_dice == 10: error_note = '1-base error for e84' elif error_dice == 9: error_note = '1-base error for e64, e68, e76, e88' elif error_dice == 8: error_note = '1-base error for e44' elif error_dice == 7: error_note = '1-base error for e60' elif error_dice == 6: error_note = '1-base error for e21, e22, e24, e28, e31, e48, e64, e72' elif error_dice == 5: error_note = f'Rare play!\n\n' \ f'**G3**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**G2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**G1**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**SI1**: {INFIELD_X_CHART["si1"]["rp"]}\n' \ f'**SI2**: {OUTFIELD_X_CHART["si2"]["rp"]}\n' elif error_dice == 4: error_note = '2-base error for e72\n' \ '1-base error for e14, e19, e20, e24, e25, e31, e80' elif error_dice == 3: error_note = '2-base error for e10, e12, e28 -> e32, e48, e84\n' \ '1-base error for e2, e5, e7, e23, e27' elif args[0][:2].upper() == 'LF' or args[0][:2].upper() == 'RF' or args[0][:2].upper() == 'CF': x_chart = 'https://sombaseball.ddns.net/static/images/season04/range-outfield.png' # Build range note if d_twenty == 1: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'F1 DO2 DO3 --TR3--\n' \ '```\n\n' elif d_twenty == 2: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'F2 SI2 DO2 DO3 TR3\n' \ '```\n\n' elif d_twenty == 3: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'F2 SI2 --DO2-- DO3\n' \ '```\n\n' elif d_twenty == 4: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'F2 F1 SI2 DO2 DO3\n' \ '```\n\n' elif d_twenty <= 6: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--F2--- --SI2-- DO2\n' \ '```\n\n' elif d_twenty == 7: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--F2--- F1 SI2 DO2\n' \ '```\n\n' elif d_twenty == 8: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--F2--- F1 --SI2--\n' \ '```\n\n' elif d_twenty <= 11: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '----F2----- --SI2--\n' \ '```\n\n' elif d_twenty <= 13: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '----F2----- F1 SI2\n' \ '```\n\n' elif d_twenty <= 15: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'F3 ----F2----- SI2\n' \ '```\n\n' elif d_twenty == 16: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--F3--- --F2--- F1\n' \ '```\n\n' elif d_twenty <= 18: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '----F3----- F2 F1\n' \ '```\n\n' elif d_twenty == 19: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '------F3------- F2\n' \ '```\n\n' elif d_twenty == 20: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--------F3---------\n' \ '```\n\n' if args[0][:2].upper() == 'LF' or args[0][:2].upper() == 'RF': error_chart += 'corner-outfield.png' if error_dice == 18: error_note = '3-base error for e4 -> e12, e19 -> e25\n' \ '2-base error for e18\n' \ '1-base error for e2, e3, e15' elif error_dice == 17: error_note = '3-base error for e13 -> e25\n' \ '2-base error for e1, e6, e8, e10' elif error_dice == 16: error_note = '2-base error for e2\n' \ '1-base error for e7 -> 12, e22, e24, e25' elif error_dice == 15: error_note = '2-base error for e3, e4, e7, e8, e10, e11, e13, e20, e21' elif error_dice == 14: error_note = '2-base error for e5, e6, e10, e12, e14, e15, e22, e23' elif error_dice == 13: error_note = '2-base error for e11, e12, e16, e20, e24, e25' elif error_dice == 12: error_note = '2-base error for e13 -> e18, e21 -> e23, e25' elif error_dice == 11: error_note = '2-base error for e9, e18 -> e21, e23 -> e25' elif error_dice == 10: error_note = '2-base error for e19' elif error_dice == 9: error_note = '2-base error for e22' elif error_dice == 8: error_note = '2-base error for e24' elif error_dice == 7: error_note = '1-base error for e19 -> e21, e23' elif error_dice == 6: error_note = '2-base error for e7, e8\n' \ '1-base error for e13 -> e18, e22, e24, e25' elif error_dice == 5: error_note = f'Rare play!' error_note1 = f'**F1**: {OUTFIELD_X_CHART["f1"]["rp"]}\n' \ f'**F2**: {OUTFIELD_X_CHART["f2"]["rp"]}\n' \ f'**F3**: {OUTFIELD_X_CHART["f3"]["rp"]}\n' error_note2 = f'**SI2**: {OUTFIELD_X_CHART["si2"]["rp"]}\n' \ f'**DO2**: {OUTFIELD_X_CHART["do2"]["rp"]}\n' \ f'**DO3**: {OUTFIELD_X_CHART["do3"]["rp"]}\n' \ f'**TR3**: {OUTFIELD_X_CHART["tr3"]["rp"]}\n' elif error_dice == 4: error_note = '2-base error for e13, e16, e20, e23 -> e25\n' \ '1-base error for e4 -> e6, e10 -> 12, e16 -> e18' elif error_dice == 3: error_note = '3-base error for e8 -> e12, e24, e25\n' \ '2-base error for e19\n' \ '1-base error for e1 -> e3, e6, e14, e15, e18, e20 -> e22' else: error_chart += 'center-field.png' if error_dice == 18: error_note = '3-base error for e4 -> 19\n' \ '2-base error for e2, e25\n' \ '1-base error for e3, e23' elif error_dice == 17: error_note = '3-base error for e20 -> e25\n' \ '2-base error for e1, e2, e5, e7, e9, e13 -> e15, e17' elif error_dice == 16: error_note = '2-base error for e3 -> e5, e8, e23\n' \ '1-base error for e10 -> e18' elif error_dice == 15: error_note = '2-base error for e6 -> e8, e12, e13, e19' elif error_dice == 14: error_note = '2-base error for e9, e10, e16 -> e18, e20 -> e23' elif error_dice == 13: error_note = '2-base error for e11, e18, e20, e23 -> e25' elif error_dice == 12: error_note = '2-base error for e14, e15, e21, e22, e24' elif error_dice == 11: error_note = '2-base error for e19, e25' elif error_dice >= 8: error_note = 'No error' elif error_dice == 7: error_note = '2-base error for e16, e17' elif error_dice == 6: error_note = '2-base error for e12, e13\n' \ '1-base error for e19 -> e25' elif error_dice == 5: error_note = f'Rare play!' error_note1 = f'**F1**: {OUTFIELD_X_CHART["f1"]["rp"]}\n' \ f'**F2**: {OUTFIELD_X_CHART["f2"]["rp"]}\n' \ f'**F3**: {OUTFIELD_X_CHART["f3"]["rp"]}\n' error_note2 = f'**SI2**: {OUTFIELD_X_CHART["si2"]["rp"]}\n' \ f'**DO2**: {OUTFIELD_X_CHART["do2"]["rp"]}\n' \ f'**DO3**: {OUTFIELD_X_CHART["do3"]["rp"]}\n' \ f'**TR3**: {OUTFIELD_X_CHART["tr3"]["rp"]}\n' elif error_dice == 4: error_note = '2-base error for e10, e12, e13, e20, e22, e23\n' \ '1-base error for e3 -> e9, e15 -> e18' elif error_dice == 3: error_note = '3-base error for e12 -> e19\n' \ '2-base error for e10, e11\n' \ '1-base error for e2, e3, e7 -> e9, e21 -> e23' elif args[0][0].upper() == 'C': x_chart = 'https://sombaseball.ddns.net/static/images/season04/range-catcher.png' error_chart += 'catcher.png' # Build range note if d_twenty == 1: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G3 ------SI1------\n' \ '```\n' elif d_twenty == 2: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G3 SPD ----SI1----\n' \ '```\n' elif d_twenty == 3: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G3--- SPD --SI1--\n' \ '```\n' elif d_twenty == 4: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G2 G3 --SPD-- SI1\n' \ '```\n' elif d_twenty == 5: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G2 --G3--- --SPD--\n' \ '```\n' elif d_twenty == 6: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G2--- G3 --SPD--\n' \ '```\n' elif d_twenty == 7: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'PO G2 G3 --SPD--\n' \ '```\n' elif d_twenty == 8: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'PO --G2--- G3 SPD\n' \ '```\n' elif d_twenty == 9: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--PO--- G2 G3 SPD\n' \ '```\n' elif d_twenty == 10: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'FO PO G2 G3 SPD\n' \ '```\n' elif d_twenty == 11: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'FO --PO--- G2 G3\n' \ '```\n' elif d_twenty == 12: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--FO--- PO G2 G3\n' \ '```\n' elif d_twenty == 13: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G1 FO PO G2 G3\n' \ '```\n' elif d_twenty == 14: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G1 --FO--- PO G2\n' \ '```\n' elif d_twenty <= 16: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G1--- FO PO G2\n' \ '```\n' elif d_twenty <= 18: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '----G1----- FO PO\n' \ '```\n' elif d_twenty == 19: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '----G1----- --FO---\n' \ '```\n' elif d_twenty == 20: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '------G1------- FO\n' \ '```\n' # Build error note # error_dice = 5 if error_dice == 18: error_note = '2-base error for e4 -> 16\n1-base error for e2, e3' elif error_dice == 17: error_note = '1-base error for e1, e2, e4, e5, e12 -> e14, e16' elif error_dice == 16: error_note = '1-base error for e3 -> e5, e7, e12 -> e14, e16' elif error_dice == 15: error_note = '1-base error for e7, e8, e12, e13, e15' elif error_dice == 14: error_note = '1-base error for e6' elif error_dice == 13: error_note = '1-base error for e9' elif error_dice == 12: error_note = '1-base error for e10, e14' elif error_dice == 11: error_note = '1-base error for e11, e15' elif 8 <= error_dice <= 10: error_note = 'No error' elif error_dice == 7: error_note = '1-base error for e16' elif error_dice == 6: error_note = '1-base error for e8, e12, e13' elif error_dice == 5: error_note = 'Rare play! Ignore range chart above and consult ranges below\n\n' error_note1 = '__If Bases Empty__\n' if d_twenty == 1: error_note1 += f'**c-1**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**c-2 -> 5**: {INFIELD_X_CHART["si1"]["rp"]}\n\n' elif d_twenty == 2: error_note1 += f'**c-1 -> 2**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**c-3 -> 5**: {INFIELD_X_CHART["si1"]["rp"]}\n\n' elif d_twenty == 3: error_note1 += f'**c-1**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-2 -> 3**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["si1"]["rp"]}\n\n' elif d_twenty == 4: error_note1 += f'**c-1 -> 2**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-3 -> 4**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["si1"]["rp"]}\n\n' elif d_twenty == 5: error_note1 += f'**c-1 -> 3**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["g3"]["rp"]}\n\n' elif d_twenty == 6: error_note1 += f'**c-1 -> 4**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["g3"]["rp"]}\n\n' elif d_twenty <= 10: error_note1 += f'**c-1 -> 5**: {INFIELD_X_CHART["po"]["rp"]}\n\n' elif d_twenty == 11: error_note1 += f'**c-1**: {INFIELD_X_CHART["fo"]["rp"]}\n' \ f'**c-2 -> 5**: {INFIELD_X_CHART["po"]["rp"]}\n\n' elif d_twenty == 12: error_note1 += f'**c-1 -> 2**: {INFIELD_X_CHART["fo"]["rp"]}\n' \ f'**c-3 -> 5**: {INFIELD_X_CHART["po"]["rp"]}\n\n' elif d_twenty == 13: error_note1 += f'**c-1 -> 3**: {INFIELD_X_CHART["fo"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["po"]["rp"]}\n\n' elif d_twenty == 14: error_note1 += f'**c-1 -> 4**: {INFIELD_X_CHART["fo"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["po"]["rp"]}\n\n' elif d_twenty <= 16: error_note1 += f'**c-1 -> 5**: {INFIELD_X_CHART["fo"]["rp"]}\n\n' elif d_twenty == 17: error_note1 += f'**c-1 -> 2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**c-3**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["fo"]["rp"]}\n\n' elif d_twenty == 18: error_note1 += f'**c-1 -> 2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**c-3 -> 4**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["fo"]["rp"]}\n\n' elif d_twenty == 19: error_note1 += f'**c-1 -> 2**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**c-3**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["g3"]["rp"]}\n\n' elif d_twenty == 20: error_note1 += f'**c-1 -> 2**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**c-3 -> 4**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["g3"]["rp"]}\n\n' error_note2 = '__If Runners on Base__\n' if d_twenty <= 2: error_note2 += f'**c-1 -> 5**: {INFIELD_X_CHART["wp"]["rp"]}\n\n' elif d_twenty == 3: error_note2 += f'**c-1**: {INFIELD_X_CHART["x"]["rp"]}\n' \ f'**c-2 -> 5**: {INFIELD_X_CHART["wp"]["rp"]}\n\n' elif d_twenty == 4: error_note2 += f'**c-1 -> 2**: {INFIELD_X_CHART["x"]["rp"]}\n' \ f'**c-3 -> 5**: {INFIELD_X_CHART["wp"]["rp"]}\n\n' elif d_twenty == 5: error_note2 += f'**c-1 -> 3**: {INFIELD_X_CHART["x"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["wp"]["rp"]}\n\n' elif d_twenty == 6: error_note2 += f'**c-1 -> 4**: {INFIELD_X_CHART["x"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["wp"]["rp"]}\n\n' elif d_twenty <= 9: error_note2 += f'**c-1**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-2 -> 5**: {INFIELD_X_CHART["x"]["rp"]}\n\n' elif d_twenty <= 12: error_note2 += f'**c-1 -> 2**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-3 -> 5**: {INFIELD_X_CHART["x"]["rp"]}\n\n' elif d_twenty == 13: error_note2 += f'**c-1**: {INFIELD_X_CHART["fo"]["rp"]}\n' \ f'**c-2**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-3 -> 5**: {INFIELD_X_CHART["x"]["rp"]}\n\n' elif d_twenty == 14: error_note2 += f'**c-1 -> 2**: {INFIELD_X_CHART["fo"]["rp"]}\n' \ f'**c-3**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["x"]["rp"]}\n\n' elif d_twenty <= 16: error_note2 += f'**c-1 -> 3**: {INFIELD_X_CHART["fo"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["x"]["rp"]}\n\n' elif d_twenty == 17: error_note2 += f'**c-1 -> 2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**c-3**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**c-4**: {INFIELD_X_CHART["po"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["x"]["rp"]}\n\n' elif d_twenty == 18: error_note2 += f'**c-1 -> 2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**c-3 -> 4**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["x"]["rp"]}\n\n' elif d_twenty == 19: error_note2 += f'**c-1**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**c-2 -> 3**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**c-4 -> 5**: {INFIELD_X_CHART["g3"]["rp"]}\n\n' elif d_twenty == 20: error_note2 += f'**c-1 -> 2**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**c-3 -> 4**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**c-5**: {INFIELD_X_CHART["g3"]["rp"]}\n\n' elif error_dice == 4: error_note = '1-base error for e5, e13' else: error_note = '2-base error for e12 -> e16\n1-base error for e2, e3, e7, e11' elif args[0][0].upper() == 'P': x_chart = 'https://sombaseball.ddns.net/static/images/season04/range-pitcher.png' error_chart += 'pitcher.png' # Build range note if d_twenty <= 2: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G3 ------SI1------\n' \ '```\n' elif d_twenty == 3: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G3--- ----SI1----\n' \ '```\n' elif d_twenty == 4: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '----G3----- --SI1--\n' \ '```\n' elif d_twenty <= 6: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '------G3------- SI1\n' \ '```\n' elif d_twenty == 7: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--------G3---------\n' \ '```\n' elif d_twenty <= 9: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G2 ------G3-------\n' \ '```\n' elif d_twenty <= 12: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ 'G1 G2 ----G3-----\n' \ '```\n' elif d_twenty == 13: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G1--- G2 --G3---\n' \ '```\n' elif d_twenty == 14: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G1--- --G2--- G3\n' \ '```\n' elif d_twenty <= 16: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--G1--- ----G2-----\n' \ '```\n' elif d_twenty <= 18: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '----G1----- --G2---\n' \ '```\n' elif d_twenty == 19: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '------G1------- G2\n' \ '```\n' elif d_twenty == 20: range_note = '```\n' \ ' 1 | 2 | 3 | 4 | 5\n' \ '--------G1---------\n' \ '```\n' # Build error note if error_dice == 18: error_note = '2-base error for e4 -> e12, e19 -> e28, e34 -> e43, e46 -> e48' elif error_dice == 17: error_note = '2-base error for e13 -> e28, e44 -> e50' elif error_dice == 16: error_note = '2-base error for e34 -> e48, e50, e51\n' \ '1-base error for e8, e11, e16, e23' elif error_dice == 15: error_note = '2-base error for e50, e51\n' \ '1-base error for e10 -> e12, e19, e20, e24, e26, e30, e35, e38, e40, e46, e47' elif error_dice == 14: error_note = '1-base error for e4, e14, e18, e21, e22, e26, e31, e35, e42, e43, e48 -> e51' elif error_dice == 13: error_note = '1-base error for e6, e13, e14, e21, e22, e26, e27, e30 -> 34, e38 -> e51' elif error_dice == 12: error_note = '1-base error for e7, e11, e12, e15 -> e19, e22 -> e51' elif error_dice == 11: error_note = '1-base error for e10, e13, e15, e17, e18, e20, e21, e23, e24, e27 -> 38, e40, e42, ' \ 'e44 -> e51' elif error_dice == 10: error_note = '1-base error for e20, e23, e24, e27 -> e51' elif error_dice == 9: error_note = '1-base error for e16, e19, e26, e28, e34 -> e36, e39 -> e51' elif error_dice == 8: error_note = '1-base error for e22, e33, e38, e39, e43 -> e51' elif error_dice == 7: error_note = '1-base error for e14, e21, e36, e39, e42 -> e44, e47 -> e51' elif error_dice == 6: error_note = '1-base error for e8, e22, e38, e39, e43 -> e51' elif error_dice == 5: error_note = f'Rare play!\n\n' \ f'**G3**: {INFIELD_X_CHART["g3"]["rp"]}\n' \ f'**G2**: {INFIELD_X_CHART["g2"]["rp"]}\n' \ f'**G1**: {INFIELD_X_CHART["g1"]["rp"]}\n' \ f'**SI1**: {INFIELD_X_CHART["si1"]["rp"]}\n' elif error_dice == 4: error_note = '1-base error for e15, e16, e40' elif error_dice == 3: error_note = '2-base error for e8 -> e12, e26 -> e28, e39 -> e43\n' \ '1-base error for e6, e7, e17, e30, e33, e44' roll_message = f'```md\n'\ f'# {str(d_twenty)},{str(d_six_one + d_six_two + d_six_three)}\n'\ f'Details:[1d20;3d6 ({d_twenty} - {d_six_one} {d_six_two} {d_six_three})]```' if range_note and error_note: embed = await self.get_dice_embed(ctx.channel, None, None) embed.title = f'{args[0][:2].upper()} Fielding Check Summary' embed.add_field(name='Range Result', value=range_note, inline=False) embed.add_field(name='Error Result', value=error_note, inline=False) embed.add_field(name='Help Commands', value=f'Run ! for full chart readout (e.g. `!g1` or `!do3`)') embed.add_field(name='Range Chart', value=x_chart, inline=False) embed.add_field(name='Error Chart', value=error_chart, inline=False) embed.add_field(name='Result Reference', value=symbol_link, inline=False) drama_roll = random.randint(1, 20) sixes = d_six_one + d_six_two + d_six_three if (d_twenty < 6 and drama_roll > 10) or (sixes > 14 and drama_roll > 10): await ctx.channel.send( f'Ope, this looks like a tough play. I wonder if it\'s going to slip by the defender ' f'{await get_emoji(ctx, "realeyes")}' ) await asyncio.sleep(2) await ctx.channel.send( content=None, embed=await self.get_dice_embed( ctx.channel, f'SA Fielding roll for {ctx.author.name}', roll_message ) ) await ctx.send(content=None, embed=embed) if error_note1: await ctx.send(content=error_note1) if error_note2: await ctx.send(content=error_note2) else: await ctx.channel.send( content=None, embed=await self.get_dice_embed( ctx.channel, f'SA Fielding roll for {ctx.author.name}', roll_message ) ) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'threedsix': d_six_one + d_six_two + d_six_three, 'dtwenty': d_twenty } self.rolls.append(this_roll) @commands.command(name='s', aliases=['shift']) async def shift_roll(self, ctx): """ Make an infield shift roll. """ team = None d_six_one = random.randint(1, 6) d_twenty = random.randint(1, 20) d_twenty_two = random.randint(1, 20) embed = None if d_twenty < 3: roll_message = f'```md\nHit into shift, consult chart```\n' \ f'At bat roll for {ctx.author.name}\n```md\n# {d_six_one},{d_twenty_two}' \ f'\nDetails:[1d6;1d20 ({d_six_one} - {d_twenty_two})]```' embed = await self.get_dice_embed(ctx.channel, None, None) embed.title = 'Hit Into Shift Results' embed.set_image(url='https://lh3.googleusercontent.com/rouutaPsSd58B7XhGMc_uyo1CIP6I9QGRLnD0ZilizVoyaenKA' 'GxHETVfsNisQ3rfxbIRYcRuiBxpMZVG-7lH0TvDHgipV6UW2XH7eWhDS4egEAXOyrjuOgqZVi72Uc2TItcIo' 'hV8y5neRrck_N6juJzIsSm2YlZz5Pqyk_jRckK2qqyI5t15uBpoY9XbjmvgkJDNyaKBQYh7TgHd42BMzanYo' 'Gr0gmCgLpiRcYxA3qEpSnxEzL7XGYODczTj6kiPOknFc6vQtcLoZ75wYqqU1AG9u5URKOckIworz0uJxrFaR' 'PwewW5Fnxj36tf6bO37zl-RuH-veLBADtFmdEUT0pGt8eCmoB7YD6WtFG048Ox0n7U_QI3xIsvpMsnIVjml_' 'sKQ55cHqsMZbnJLFXIO73Fl4xQFS1eqI-FjzwvK_kmslPznxfb0uz-WtBQ3fTUV--07ya-b_n4O0H38IVKKa' 'eQqKzdTjU6Uv0uV8375UsNdSif5cbsfBp7_qlrZx4zFWc-IafCNh3h5R_NqLBV_-VQVqQdyu15Mbjr3s7kwB' 'DANYsk9zv3grE1yoKzzAPtRILXxPpJz6MkXDPNSTDPOd6ZXR7uoyevt5BvvcWnf7Htgai8WtKHp3Zcd_bIGJ' 'sGhohp4g3JO8zK5WMKN3-Za-KxH9XxDwrik-dc05x5VeX99m2A9eKClNbQGdE4TaI=w632-h292-no?authu' 'ser=0') else: roll_message = f'```md\n' if d_twenty < 9 and d_six_one > 3: roll_message += f'Swing away, HR becomes 2B if beating the shift```\n' else: roll_message += f'Swing away, no effect```\n' await ctx.channel.send( content=None, embed=await self.get_dice_embed( ctx.channel, f'Shift roll for {ctx.author.name}', roll_message ) ) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'dsix': d_six_one, 'dtwenty': d_twenty } self.rolls.append(this_roll) this_roll = { 'season': self.current['season'], 'week': self.current['week'], 'team_id': team["id"] if team else None, 'roller': ctx.author.id, 'dtwenty': d_twenty_two } self.rolls.append(this_roll) @commands.command( name='lookups', help='Fielding chart lookup', aliases=['si1', 'si2', 'do2', 'do3', 'tr3', 'f1', 'f2', 'f3', 'po', 'wp', 'x', 'fo', 'g1', 'g2', 'g3']) async def fielding_chart_x(self, ctx): this_command = ctx.message.content.split(" ")[0][1:] chart_data = get_xchart_data(this_command) if not chart_data: await ctx.send('Ope. Something went wrong pulling that info. Sorry about that.') return await ctx.send(chart_data) if this_command in ['g1', 'g2', 'g3']: embeds = get_groundball_embeds(this_command) await ctx.send(content=None, embed=embeds[0]) @commands.command(name='groundball', aliases=['gba', 'gbb', 'gbc'], help='Groundball charts') async def groundball_chart(self, ctx): this_command = ctx.message.content.split(" ")[0][1:] embeds = get_groundball_embeds(this_command) await ctx.send(content=None, embed=embeds[0]) await ctx.send(content=None, embed=embeds[1]) @commands.command(name='roll', aliases=['r'], help='roll XdY') async def roll_command(self, ctx, roll_string): if not re.search('[0-9]+d[0-9]+', roll_string.lower()): await ctx.send('Please format the dice as **X**d**Y** and try again.') return numbers = re.split('d', roll_string.lower()) logging.info(f'numbers: {numbers}') num_dice = int(numbers[0]) die_sides = int(numbers[1]) all_rolls = [] total = 0 logging.info(f'num_dice: {num_dice} / die_sides: {die_sides}') if num_dice < 1 or die_sides < 1: await ctx.send('Hurr hurr, let\'s roll negative dice, amirite!') return if num_dice * die_sides > 100000: await ctx.send('Ain\'t nobody got time for dat!') return for x in range(num_dice): this_roll = random.randint(1, die_sides) total += this_roll all_rolls.append(f'{this_roll}') roll_message = f'```md\n' \ f'# {total}\n' \ f'Details: [{num_dice}d{die_sides} ({" ".join(all_rolls)})]\n```' await ctx.channel.send( content=None, embed=await self.get_dice_embed( ctx.channel, f'{num_dice}d{die_sides} roll for {ctx.author.name}', roll_message ) ) async def setup(bot): await bot.add_cog(Dice(bot))