112 lines
4.3 KiB
Python
112 lines
4.3 KiB
Python
import asyncio
|
|
from db_calls import db_get
|
|
import pandas as pd
|
|
|
|
|
|
async def main():
|
|
"""Check Joe Boyle's specific stats"""
|
|
|
|
# Get cardset
|
|
c_query = await db_get('cardsets', params=[('name', '2025 Season')])
|
|
cardset_id = c_query['cardsets'][0]['id']
|
|
print(f'Checking Joe Boyle in cardset: 2025 Season (ID: {cardset_id})\n')
|
|
|
|
# Get Joe Boyle's player record
|
|
p_query = await db_get('players', params=[('cardset_id', cardset_id)])
|
|
players_df = pd.DataFrame(p_query['players'])
|
|
|
|
joe_boyle = players_df[players_df['p_name'].str.contains('Joe Boyle', case=False, na=False)]
|
|
|
|
if len(joe_boyle) == 0:
|
|
print("Joe Boyle not found!")
|
|
return
|
|
|
|
player_id = joe_boyle.iloc[0]['player_id']
|
|
|
|
if isinstance(joe_boyle.iloc[0]['rarity'], dict):
|
|
rarity_id = joe_boyle.iloc[0]['rarity']['id']
|
|
else:
|
|
rarity_id = joe_boyle.iloc[0]['rarity']
|
|
|
|
print(f"Player: {joe_boyle.iloc[0]['p_name']}")
|
|
print(f"Player ID: {player_id}")
|
|
print(f"Rarity: {rarity_id}")
|
|
print(f"Cost: {joe_boyle.iloc[0]['cost']}")
|
|
print()
|
|
|
|
# Get pitching card
|
|
pc_query = await db_get('pitchingcards', params=[('player_id', player_id), ('cardset_id', cardset_id)])
|
|
if pc_query and pc_query['count'] > 0:
|
|
pitching_card = pc_query['cards'][0]
|
|
print(f"Pitching Card ID: {pitching_card['id']}")
|
|
print(f"Starter Rating: {pitching_card['starter_rating']}")
|
|
print(f"Relief Rating: {pitching_card['relief_rating']}")
|
|
print(f"Hand: {pitching_card['hand']}")
|
|
print()
|
|
|
|
pitchingcard_id = pitching_card['id']
|
|
|
|
# Get ratings vs L and vs R
|
|
vl_query = await db_get('pitchingcardratings', params=[
|
|
('pitchingcard_id', pitchingcard_id), ('vs_hand', 'L')
|
|
], timeout=10)
|
|
vr_query = await db_get('pitchingcardratings', params=[
|
|
('pitchingcard_id', pitchingcard_id), ('vs_hand', 'R')
|
|
], timeout=10)
|
|
|
|
if vl_query and vl_query['count'] > 0:
|
|
vl_rating = vl_query['ratings'][0]
|
|
print("vs Left-Handed Hitters:")
|
|
print(f" OBP: {vl_rating['obp']:.3f}")
|
|
print(f" SLG: {vl_rating['slg']:.3f}")
|
|
print(f" OPS: {vl_rating['obp'] + vl_rating['slg']:.3f}")
|
|
print()
|
|
else:
|
|
print("No ratings found vs LHH")
|
|
|
|
if vr_query and vr_query['count'] > 0:
|
|
vr_rating = vr_query['ratings'][0]
|
|
print("vs Right-Handed Hitters:")
|
|
print(f" OBP: {vr_rating['obp']:.3f}")
|
|
print(f" SLG: {vr_rating['slg']:.3f}")
|
|
print(f" OPS: {vr_rating['obp'] + vr_rating['slg']:.3f}")
|
|
print()
|
|
else:
|
|
print("No ratings found vs RHH")
|
|
|
|
if vl_query and vl_query['count'] > 0 and vr_query and vr_query['count'] > 0:
|
|
ops_vl = vl_rating['obp'] + vl_rating['slg']
|
|
ops_vr = vr_rating['obp'] + vr_rating['slg']
|
|
total_ops = (ops_vr + ops_vl + max(ops_vl, ops_vr)) / 3
|
|
|
|
print(f"Total OPS (using max formula): {total_ops:.3f}")
|
|
print()
|
|
|
|
# Show threshold logic
|
|
starter_rating = pitching_card['starter_rating']
|
|
print(f"Rarity Assignment Logic:")
|
|
if starter_rating > 3:
|
|
print(f" Starter (rating {starter_rating} > 3)")
|
|
print(f" Thresholds:")
|
|
print(f" Hall of Fame (99): <= 0.4 {'<-- ASSIGNED' if total_ops <= 0.4 else ''}")
|
|
print(f" Diamond (1): <= 0.475")
|
|
print(f" Gold (2): <= 0.53")
|
|
print(f" Silver (3): <= 0.6")
|
|
print(f" Bronze (4): <= 0.675")
|
|
print(f" Common (5): > 0.675")
|
|
else:
|
|
print(f" Reliever (rating {starter_rating} <= 3)")
|
|
print(f" Thresholds:")
|
|
print(f" Hall of Fame (99): <= 0.325 {'<-- ASSIGNED' if total_ops <= 0.325 else ''}")
|
|
print(f" Diamond (1): <= 0.4")
|
|
print(f" Gold (2): <= 0.475")
|
|
print(f" Silver (3): <= 0.55")
|
|
print(f" Bronze (4): <= 0.625")
|
|
print(f" Common (5): > 0.625")
|
|
else:
|
|
print("No pitching card found!")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|