From a2e374cd4fe168b3089ecee316f22407031f6718 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Sat, 21 Mar 2026 00:02:01 -0500 Subject: [PATCH] fix: correct get_of() opposite-field direction for switch hitters Switch hitters batting vs LHP hit right-handed (pull=lf, oppo=rf). Switch hitters batting vs RHP hit left-handed (pull=rf, oppo=lf). Copy-paste error had both pull_side branches returning the same value. Closes #5 Co-Authored-By: Claude Sonnet 4.6 --- creation_helpers.py | 48 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/creation_helpers.py b/creation_helpers.py index f1081e0..53d0535 100644 --- a/creation_helpers.py +++ b/creation_helpers.py @@ -595,21 +595,21 @@ def legal_splits(tot_chances): def result_string(tba_data, row_num, split_min=None, split_max=None): - bold1 = f'{"" if tba_data["bold"] else ""}' - bold2 = f'{"" if tba_data["bold"] else ""}' - row_string = f'{" " if int(row_num) < 10 else ""}{row_num}' + bold1 = f"{'' if tba_data['bold'] else ''}" + bold2 = f"{'' if tba_data['bold'] else ''}" + row_string = f"{' ' if int(row_num) < 10 else ''}{row_num}" if TESTING: print( - f'adding {tba_data["string"]} to row {row_num} / ' + f"adding {tba_data['string']} to row {row_num} / " f"split_min: {split_min} / split_max: {split_max}" ) # No splits; standard result if not split_min: - return f'{bold1}{row_string}-{tba_data["string"]}{bold2}' + return f"{bold1}{row_string}-{tba_data['string']}{bold2}" # With splits - split_nums = f'{split_min if split_min != 20 else ""}{"-" if split_min != 20 else ""}{split_max}' + split_nums = f"{split_min if split_min != 20 else ''}{'-' if split_min != 20 else ''}{split_max}" data_string = ( tba_data["sm-string"] if "sm-string" in tba_data.keys() else tba_data["string"] ) @@ -638,41 +638,39 @@ def result_string(tba_data, row_num, split_min=None, split_max=None): row_output = " " if TESTING: print(f"row_output: {row_output}") - return f'{bold1}{row_output}{data_string}{" " * spaces}{split_nums}{bold2}' + return f"{bold1}{row_output}{data_string}{' ' * spaces}{split_nums}{bold2}" def result_data( tba_data, row_num, tba_data_bottom=None, top_split_max=None, fatigue=False ): ret_data = {} - top_bold1 = f'{"" if tba_data["bold"] else ""}' - top_bold2 = f'{"" if tba_data["bold"] else ""}' + top_bold1 = f"{'' if tba_data['bold'] else ''}" + top_bold2 = f"{'' if tba_data['bold'] else ''}" bot_bold1 = None bot_bold2 = None if tba_data_bottom: - bot_bold1 = f'{"" if tba_data_bottom["bold"] else ""}' - bot_bold2 = f'{"" if tba_data_bottom["bold"] else ""}' + bot_bold1 = f"{'' if tba_data_bottom['bold'] else ''}" + bot_bold2 = f"{'' if tba_data_bottom['bold'] else ''}" if tba_data_bottom is None: ret_data["2d6"] = f"{top_bold1}{int(row_num)}-{top_bold2}" ret_data["splits"] = f"{top_bold1}‎{top_bold2}" ret_data["result"] = ( - f"{top_bold1}" - f'{tba_data["string"]}{" •" if fatigue else ""}' - f"{top_bold2}" + f"{top_bold1}{tba_data['string']}{' •' if fatigue else ''}{top_bold2}" ) else: ret_data["2d6"] = f"{top_bold1}{int(row_num)}-{top_bold2}\n" ret_data["splits"] = ( - f'{top_bold1}1{"-" if top_split_max != 1 else ""}' - f'{top_split_max if top_split_max != 1 else ""}{top_bold2}\n' - f'{bot_bold1}{top_split_max+1}{"-20" if top_split_max != 19 else ""}{bot_bold2}' + f"{top_bold1}1{'-' if top_split_max != 1 else ''}" + f"{top_split_max if top_split_max != 1 else ''}{top_bold2}\n" + f"{bot_bold1}{top_split_max + 1}{'-20' if top_split_max != 19 else ''}{bot_bold2}" ) ret_data["result"] = ( - f'{top_bold1}{tba_data["sm-string"] if "sm-string" in tba_data.keys() else tba_data["string"]}' + f"{top_bold1}{tba_data['sm-string'] if 'sm-string' in tba_data.keys() else tba_data['string']}" f"{top_bold2}\n" f"{bot_bold1}" - f'{tba_data_bottom["sm-string"] if "sm-string" in tba_data_bottom.keys() else tba_data_bottom["string"]}' + f"{tba_data_bottom['sm-string'] if 'sm-string' in tba_data_bottom.keys() else tba_data_bottom['string']}" f"{bot_bold2}" ) @@ -688,9 +686,9 @@ def get_of(batter_hand, pitcher_hand, pull_side=True): if batter_hand == "S": if pitcher_hand == "L": - return "rf" if pull_side else "rf" + return "lf" if pull_side else "rf" else: - return "lf" if pull_side else "lf" + return "rf" if pull_side else "lf" def get_col(col_num): @@ -729,7 +727,7 @@ def get_position_string(all_pos: list, inc_p: bool): for x in all_pos: if x.position == "OF": - of_arm = f'{"+" if "-" not in x.arm else ""}{x.arm}' + of_arm = f"{'+' if '-' not in x.arm else ''}{x.arm}" of_error = x.error of_innings = x.innings elif x.position == "CF": @@ -744,7 +742,7 @@ def get_position_string(all_pos: list, inc_p: bool): elif x.position == "C": all_def.append( ( - f'c-{x.range}({"+" if int(x.arm) >= 0 else ""}{x.arm}) e{x.error} T-{x.overthrow}(pb-{x.pb})', + f"c-{x.range}({'+' if int(x.arm) >= 0 else ''}{x.arm}) e{x.error} T-{x.overthrow}(pb-{x.pb})", x.innings, ) ) @@ -1079,7 +1077,7 @@ def mlbteam_and_franchise(mlbam_playerid): p_data["franchise"] = normalize_franchise(data["currentTeam"]["name"]) else: logger.error( - f'Could not set team for {mlbam_playerid}; received {data["currentTeam"]["name"]}' + f"Could not set team for {mlbam_playerid}; received {data['currentTeam']['name']}" ) else: logger.error( @@ -1222,5 +1220,5 @@ def get_hand(df_data): else: return "R" except Exception: - logger.error(f'Error in get_hand for {df_data["Name"]}') + logger.error(f"Error in get_hand for {df_data['Name']}") return "R"