Adding new stats to /plays
This commit is contained in:
parent
f60c1deea7
commit
ebab737093
120
cogs/players.py
120
cogs/players.py
@ -1240,7 +1240,7 @@ class Players(commands.Cog):
|
|||||||
await interaction.edit_original_response(content='Here I go sheetsing again...', view=None)
|
await interaction.edit_original_response(content='Here I go sheetsing again...', view=None)
|
||||||
logging.info(f'sba-submit - reading scorecard')
|
logging.info(f'sba-submit - reading scorecard')
|
||||||
playtable = scorecard.worksheet_by_title('Playtable')
|
playtable = scorecard.worksheet_by_title('Playtable')
|
||||||
all_plays = playtable.get_values('B3', 'BG300')
|
all_plays = playtable.get_values('B3', 'BW300')
|
||||||
logging.debug(f'all_plays: {all_plays}')
|
logging.debug(f'all_plays: {all_plays}')
|
||||||
|
|
||||||
play_keys = [
|
play_keys = [
|
||||||
@ -1250,7 +1250,10 @@ class Players(commands.Cog):
|
|||||||
'e_run', 'hit', 'rbi', 'double', 'triple', 'homerun', 'bb', 'so', 'hbp', 'sac', 'ibb', 'gidp',
|
'e_run', 'hit', 'rbi', 'double', 'triple', 'homerun', 'bb', 'so', 'hbp', 'sac', 'ibb', 'gidp',
|
||||||
'bphr', 'bpfo', 'bp1b', 'bplo', 'sb', 'cs', 'outs', 'pitcher_rest_outs', 'wpa', 'catcher_id', 'defender_id',
|
'bphr', 'bpfo', 'bp1b', 'bplo', 'sb', 'cs', 'outs', 'pitcher_rest_outs', 'wpa', 'catcher_id', 'defender_id',
|
||||||
'runner_id', 'check_pos', 'error', 'wild_pitch', 'passed_ball', 'pick_off', 'balk', 'is_go_ahead',
|
'runner_id', 'check_pos', 'error', 'wild_pitch', 'passed_ball', 'pick_off', 'balk', 'is_go_ahead',
|
||||||
'is_tied', 'is_new_inning', 'inherited_runners', 'inherited_scored', 'on_hook_for_loss', 'run_differential'
|
'is_tied', 'is_new_inning', 'inherited_runners', 'inherited_scored', 'on_hook_for_loss', 'run_differential',
|
||||||
|
'unused-manager', 'unused-pitcherpow', 'unused-pitcherrestip', 'unused-runners', 'unused-fatigue',
|
||||||
|
'unused-roundedip', 'unused-elitestart', 'unused-scenario', 'unused-winxaway', 'unused-winxhome',
|
||||||
|
'unused-pinchrunner', 'unused-order', 'hand_batting', 'hand_pitching', 're24_primary', 're24_running'
|
||||||
]
|
]
|
||||||
p_data = []
|
p_data = []
|
||||||
for line in all_plays:
|
for line in all_plays:
|
||||||
@ -1285,7 +1288,8 @@ class Players(commands.Cog):
|
|||||||
try:
|
try:
|
||||||
g_resp = await db_patch('games', object_id=this_game['id'], params=[
|
g_resp = await db_patch('games', object_id=this_game['id'], params=[
|
||||||
('away_score', int(score_table[0][0])), ('home_score', int(score_table[1][0])),
|
('away_score', int(score_table[0][0])), ('home_score', int(score_table[1][0])),
|
||||||
('away_manager_id', away_manager['id']), ('home_manager_id', home_manager['id']), ('game_num', game_num)
|
('away_manager_id', away_manager['id']), ('home_manager_id', home_manager['id']),
|
||||||
|
('game_num', game_num), ('scorecard_url', sheet_url)
|
||||||
])
|
])
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logging.error(f'PATCH game error: {e}')
|
logging.error(f'PATCH game error: {e}')
|
||||||
@ -1297,12 +1301,12 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
# Pull pitching decisions
|
# Pull pitching decisions
|
||||||
pitching = scorecard.worksheet_by_title('Pitcherstats')
|
pitching = scorecard.worksheet_by_title('Pitcherstats')
|
||||||
all_decisions = pitching.get_values('B3', 'N30')
|
all_decisions = pitching.get_values('B3', 'O30')
|
||||||
logging.info(f'all_decisions: {all_decisions}')
|
logging.info(f'all_decisions: {all_decisions}')
|
||||||
|
|
||||||
pit_keys = [
|
pit_keys = [
|
||||||
'pitcher_id', 'rest_ip', 'is_start', 'base_rest', 'extra_rest', 'rest_required', 'win',
|
'pitcher_id', 'rest_ip', 'is_start', 'base_rest', 'extra_rest', 'rest_required', 'win',
|
||||||
'loss', 'is_save', 'hold', 'b_save', 'irunners', 'irunners_scored'
|
'loss', 'is_save', 'hold', 'b_save', 'irunners', 'irunners_scored', 'team_id'
|
||||||
]
|
]
|
||||||
pit_data = []
|
pit_data = []
|
||||||
wp = None
|
wp = None
|
||||||
@ -2004,59 +2008,59 @@ class Players(commands.Cog):
|
|||||||
embed.set_image(url=f'{SBA_BASE_URL}/static/images/pitbat/card-{card_num}.png')
|
embed.set_image(url=f'{SBA_BASE_URL}/static/images/pitbat/card-{card_num}.png')
|
||||||
await ctx.send(content=None, embed=embed)
|
await ctx.send(content=None, embed=embed)
|
||||||
|
|
||||||
@app_commands.command(name='keepers', description='Mod: Set team keepers')
|
# @app_commands.command(name='keepers', description='Mod: Set team keepers')
|
||||||
@app_commands.checks.has_any_role('Da Commish')
|
# @app_commands.checks.has_any_role('Da Commish')
|
||||||
async def set_keepers_slash(
|
# async def set_keepers_slash(
|
||||||
self, interaction: discord.Interaction, team_abbrev: str, keep1: str = None, keep2: str = None,
|
# self, interaction: discord.Interaction, team_abbrev: str, keep1: str = None, keep2: str = None,
|
||||||
keep3: str = None, keep4: str = None, keep5: str = None, keep6: str = None, keep7: str = None):
|
# keep3: str = None, keep4: str = None, keep5: str = None, keep6: str = None, keep7: str = None):
|
||||||
await interaction.response.defer()
|
# await interaction.response.defer()
|
||||||
current = await db_get('current')
|
# current = await db_get('current')
|
||||||
team = await get_team_by_abbrev(team_abbrev, current['season'])
|
# team = await get_team_by_abbrev(team_abbrev, current['season'])
|
||||||
|
#
|
||||||
keepers = []
|
# keepers = []
|
||||||
keeper_string = ''
|
# keeper_string = ''
|
||||||
keeper_swar = 0
|
# keeper_swar = 0
|
||||||
|
#
|
||||||
def get_pos_abbrev(position):
|
# def get_pos_abbrev(position):
|
||||||
if 'B' in position:
|
# if 'B' in position:
|
||||||
return 'IF'
|
# return 'IF'
|
||||||
if 'F' in position:
|
# if 'F' in position:
|
||||||
return 'OF'
|
# return 'OF'
|
||||||
if 'P' in position:
|
# if 'P' in position:
|
||||||
return 'P'
|
# return 'P'
|
||||||
if position == 'C':
|
# if position == 'C':
|
||||||
return 'C'
|
# return 'C'
|
||||||
return 'DH'
|
# return 'DH'
|
||||||
|
#
|
||||||
for x in [keep1, keep2, keep3, keep4, keep5, keep6, keep7]:
|
# for x in [keep1, keep2, keep3, keep4, keep5, keep6, keep7]:
|
||||||
if x:
|
# if x:
|
||||||
p_name = await fuzzy_player_search(
|
# p_name = await fuzzy_player_search(
|
||||||
interaction, interaction.channel, self.bot, x, self.player_list.keys(), author=interaction.user
|
# interaction, interaction.channel, self.bot, x, self.player_list.keys(), author=interaction.user
|
||||||
)
|
# )
|
||||||
this_p = await get_player_by_name(current['season'], p_name)
|
# this_p = await get_player_by_name(current['season'], p_name)
|
||||||
keepers.append(this_p)
|
# keepers.append(this_p)
|
||||||
keeper_string += f'{get_pos_abbrev(this_p["pos_1"])} - {this_p["name"]} ({this_p["wara"]:.2f})\n'
|
# keeper_string += f'{get_pos_abbrev(this_p["pos_1"])} - {this_p["name"]} ({this_p["wara"]:.2f})\n'
|
||||||
keeper_swar += this_p['wara']
|
# keeper_swar += this_p['wara']
|
||||||
|
#
|
||||||
await interaction.response.send_message(content=f'{team["sname"]} Keepers:\n{keeper_string}')
|
# await interaction.response.send_message(content=f'{team["sname"]} Keepers:\n{keeper_string}')
|
||||||
all_players = await db_get('players', api_ver=3, params=[('team_abbrev', team['abbrev'])])
|
# all_players = await db_get('players', api_ver=3, params=[('team_abbrev', team['abbrev'])])
|
||||||
logging.info(f'all_players: {all_players}')
|
# logging.info(f'all_players: {all_players}')
|
||||||
|
#
|
||||||
fa = await get_team_by_abbrev('FA', current['season'])
|
# fa = await get_team_by_abbrev('FA', current['season'])
|
||||||
for y in all_players['players']:
|
# for y in all_players['players']:
|
||||||
if y not in keepers:
|
# if y not in keepers:
|
||||||
y['team'] = fa
|
# y['team'] = fa
|
||||||
await patch_player(y)
|
# await patch_player(y)
|
||||||
|
#
|
||||||
await interaction.channel.send(
|
# await interaction.channel.send(
|
||||||
f'Just yeeted **{len(all_players["players"]) - len(keepers)}** players into the sun!'
|
# f'Just yeeted **{len(all_players["players"]) - len(keepers)}** players into the sun!'
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
embed = get_team_embed(title=f'{team["lname"]} Keepers', team=team)
|
# embed = get_team_embed(title=f'{team["lname"]} Keepers', team=team)
|
||||||
embed.add_field(name=f'Keepers', value=keeper_string)
|
# embed.add_field(name=f'Keepers', value=keeper_string)
|
||||||
embed.add_field(name='Total sWAR', value=f'{keeper_swar:.2f}')
|
# embed.add_field(name='Total sWAR', value=f'{keeper_swar:.2f}')
|
||||||
|
#
|
||||||
await send_to_channel(self.bot, 'sba-network-news', content=None, embed=embed)
|
# await send_to_channel(self.bot, 'sba-network-news', content=None, embed=embed)
|
||||||
|
|
||||||
group_publish = app_commands.Group(name='publish', description='Make a scorecard publicly accessible')
|
group_publish = app_commands.Group(name='publish', description='Make a scorecard publicly accessible')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user