Update card_creation.py
Bug fix: add second arm rating for C + OF players
This commit is contained in:
parent
e217375974
commit
a31f451089
@ -1191,7 +1191,8 @@ class FullPitchingCard(FullCard):
|
|||||||
|
|
||||||
def get_pos_data(all_pos, is_pitcher: bool = False) -> dict:
|
def get_pos_data(all_pos, is_pitcher: bool = False) -> dict:
|
||||||
final = ''
|
final = ''
|
||||||
arm_added = False
|
of_arm_added = False
|
||||||
|
c_arm_added = False
|
||||||
first = True
|
first = True
|
||||||
for x in all_pos:
|
for x in all_pos:
|
||||||
if is_pitcher:
|
if is_pitcher:
|
||||||
@ -1206,15 +1207,22 @@ def get_pos_data(all_pos, is_pitcher: bool = False) -> dict:
|
|||||||
final += x.position.lower()
|
final += x.position.lower()
|
||||||
if x.position != 'DH':
|
if x.position != 'DH':
|
||||||
final += f'-{x.range}'
|
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})'
|
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}'
|
final += f'e{x.error}'
|
||||||
if x.position == 'C':
|
if x.position == 'C':
|
||||||
final += f' T-{x.overthrow}(pb {x.pb})'
|
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
|
font = 16
|
||||||
margin = 5
|
margin = 5
|
||||||
elif len(final) >= 46:
|
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):
|
def full_log(this_ratings, this_card, info=False):
|
||||||
if info:
|
if info:
|
||||||
logging.info(
|
logging.debug(
|
||||||
f'Rating Chances: {this_ratings.total_chances()} / Card Chances: {this_card.total_chances()}\n'
|
f'Rating Chances: {this_ratings.total_chances()} / Card Chances: {this_card.total_chances()}\n'
|
||||||
f'{this_card.sample_output()}\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()
|
vl_total = new_battingratings[0].total_chances()
|
||||||
vr_total = new_battingratings[1].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'
|
logging.info(f'New Ratings\nTotal Chances:\n{vl_total}\n{new_battingratings[0]}')
|
||||||
f'Total Chances: {vr_total}\n{new_battingratings[1]}')
|
logging.debug(f'Total Chances: {vr_total}\n{new_battingratings[1]}')
|
||||||
|
|
||||||
if vl_total + vr_total != Decimal(216):
|
if vl_total + vr_total != Decimal(216):
|
||||||
raise ValueError(f'vl chances: {vl_total} / vr chances: {vr_total}')
|
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
|
retries += 1
|
||||||
|
|
||||||
log_data = vl.sample_output() if data.vs_hand == 'L' else vr.sample_output()
|
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(
|
plays = sorted(
|
||||||
[(data.strikeout, 'so'), (data.groundout_a, 'gb'), (data.flyout_lf_b, 'lf'), (data.flyout_rf_b, 'rf')],
|
[(data.strikeout, 'so'), (data.groundout_a, 'gb'), (data.flyout_lf_b, 'lf'), (data.flyout_rf_b, 'rf')],
|
||||||
key=lambda z: z[0],
|
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()
|
vl_total = new_pitchingratings[0].total_chances()
|
||||||
vr_total = new_pitchingratings[1].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'
|
logging.info(f'New Ratings\nTotal Chances:\n{vl_total}\n{new_pitchingratings[0]}')
|
||||||
f'Total Chances: {vr_total}\n{new_pitchingratings[1]}')
|
logging.debug(f'Total Chances: {vr_total}\n{new_pitchingratings[1]}')
|
||||||
|
|
||||||
pos_data = get_pos_data(positions, is_pitcher=True)
|
pos_data = get_pos_data(positions, is_pitcher=True)
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user