Update card_creation.py

Bug fix: add second arm rating for C + OF players
This commit is contained in:
Cal Corum 2024-02-24 21:36:44 -06:00
parent e217375974
commit a31f451089

View File

@ -1191,7 +1191,8 @@ class FullPitchingCard(FullCard):
def get_pos_data(all_pos, is_pitcher: bool = False) -> dict:
final = ''
arm_added = False
of_arm_added = False
c_arm_added = False
first = True
for x in all_pos:
if is_pitcher:
@ -1206,15 +1207,22 @@ def get_pos_data(all_pos, is_pitcher: bool = False) -> dict:
final += x.position.lower()
if x.position != 'DH':
final += f'-{x.range}'
if x.position in ['LF', 'CF', 'RF', 'C'] and not arm_added:
if x.position in ['LF', 'CF', 'RF'] and not of_arm_added:
final += f'({"+" if x.arm >= 0 else ""}{x.arm})'
arm_added = True
of_arm_added = True
if x.position == 'C' and not c_arm_added:
final += f'({"+" if x.arm >= 0 else ""}{x.arm})'
c_arm_added = True
final += f'e{x.error}'
if x.position == 'C':
final += f' T-{x.overthrow}(pb {x.pb})'
if len(final) >= 50:
if len(final) >= 56:
font = 14
margin = 7
elif len(final) >= 50:
font = 16
margin = 5
elif len(final) >= 46:
@ -1238,7 +1246,7 @@ def get_pos_data(all_pos, is_pitcher: bool = False) -> dict:
def full_log(this_ratings, this_card, info=False):
if info:
logging.info(
logging.debug(
f'Rating Chances: {this_ratings.total_chances()} / Card Chances: {this_card.total_chances()}\n'
f'{this_card.sample_output()}\n'
)
@ -2166,8 +2174,8 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
vl_total = new_battingratings[0].total_chances()
vr_total = new_battingratings[1].total_chances()
logging.info(f'New Ratings\nTotal Chances:\n{vl_total}\n{new_battingratings[0]}\n\n'
f'Total Chances: {vr_total}\n{new_battingratings[1]}')
logging.info(f'New Ratings\nTotal Chances:\n{vl_total}\n{new_battingratings[0]}')
logging.debug(f'Total Chances: {vr_total}\n{new_battingratings[1]}')
if vl_total + vr_total != Decimal(216):
raise ValueError(f'vl chances: {vl_total} / vr chances: {vr_total}')
@ -2984,7 +2992,8 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
retries += 1
log_data = vl.sample_output() if data.vs_hand == 'L' else vr.sample_output()
logging.info(f'Pre-filler total chances: {new_ratings.total_chances()}\n{log_data}')
logging.info(f'Pre-filler total chances: {new_ratings.total_chances()}')
logging.debug(f'{log_data}')
plays = sorted(
[(data.strikeout, 'so'), (data.groundout_a, 'gb'), (data.flyout_lf_b, 'lf'), (data.flyout_rf_b, 'rf')],
key=lambda z: z[0],
@ -3032,8 +3041,8 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
vl_total = new_pitchingratings[0].total_chances()
vr_total = new_pitchingratings[1].total_chances()
logging.info(f'New Ratings\nTotal Chances:\n{vl_total}\n{new_pitchingratings[0]}\n\n'
f'Total Chances: {vr_total}\n{new_pitchingratings[1]}')
logging.info(f'New Ratings\nTotal Chances:\n{vl_total}\n{new_pitchingratings[0]}')
logging.debug(f'Total Chances: {vr_total}\n{new_pitchingratings[1]}')
pos_data = get_pos_data(positions, is_pitcher=True)
return {