86 lines
2.9 KiB
Python
86 lines
2.9 KiB
Python
import asyncio
|
|
from db_calls import db_get
|
|
import pandas as pd
|
|
|
|
|
|
async def main():
|
|
"""Check rarity distribution in 2025 Season cardset"""
|
|
|
|
# Get cardset
|
|
c_query = await db_get('cardsets', params=[('name', '2025 Season')])
|
|
if c_query is None or c_query['count'] == 0:
|
|
print('Cardset not found')
|
|
return
|
|
|
|
cardset = c_query['cardsets'][0]
|
|
cardset_id = cardset['id']
|
|
print(f'Checking cardset: {cardset["name"]} (ID: {cardset_id})\n')
|
|
|
|
# Get all players in this cardset
|
|
p_query = await db_get('players', params=[('cardset_id', cardset_id)])
|
|
if p_query is None or p_query['count'] == 0:
|
|
print('No players found')
|
|
return
|
|
|
|
players_df = pd.DataFrame(p_query['players'])
|
|
|
|
# Extract rarity ID if it's a dict
|
|
if isinstance(players_df['rarity'].iloc[0], dict):
|
|
players_df['rarity_id'] = players_df['rarity'].apply(lambda x: x['id'] if isinstance(x, dict) else x)
|
|
else:
|
|
players_df['rarity_id'] = players_df['rarity']
|
|
|
|
# Count rarities
|
|
rarity_counts = players_df['rarity_id'].value_counts().sort_index()
|
|
|
|
rarity_names = {
|
|
1: 'Diamond',
|
|
2: 'Gold',
|
|
3: 'Silver',
|
|
4: 'Bronze',
|
|
5: 'Common',
|
|
99: 'Hall of Fame'
|
|
}
|
|
|
|
print('Rarity Distribution:')
|
|
print('-' * 40)
|
|
total = len(players_df)
|
|
for rarity_id, count in rarity_counts.items():
|
|
rarity_name = rarity_names.get(rarity_id, f'Unknown ({rarity_id})')
|
|
pct = (count / total) * 100
|
|
print(f'{rarity_name:15} ({rarity_id:2}): {count:4} cards ({pct:5.1f}%)')
|
|
|
|
print('-' * 40)
|
|
print(f'Total: {total} cards')
|
|
|
|
# Check specifically Hall of Fame cards
|
|
hof_df = players_df[players_df['rarity_id'] == 99]
|
|
print(f'\nHall of Fame cards: {len(hof_df)}')
|
|
|
|
# Get batting and pitching cards to see the split
|
|
bc_query = await db_get('battingcards', params=[('cardset_id', cardset_id), ('short_output', True)])
|
|
pc_query = await db_get('pitchingcards', params=[('cardset_id', cardset_id), ('short_output', True)])
|
|
|
|
batting_players = pd.DataFrame(bc_query['cards'])['player'].unique() if bc_query['count'] > 0 else []
|
|
pitching_players = pd.DataFrame(pc_query['cards'])['player'].unique() if pc_query['count'] > 0 else []
|
|
|
|
hof_batters = hof_df[hof_df['player_id'].isin(batting_players)]
|
|
hof_pitchers = hof_df[hof_df['player_id'].isin(pitching_players)]
|
|
|
|
print(f' - HOF Batters: {len(hof_batters)}')
|
|
print(f' - HOF Pitchers: {len(hof_pitchers)}')
|
|
|
|
if len(hof_batters) > 0:
|
|
print('\nHOF Batters:')
|
|
for _, player in hof_batters.iterrows():
|
|
print(f' - {player["p_name"]} (ID: {player["player_id"]})')
|
|
|
|
if len(hof_pitchers) > 0:
|
|
print('\nHOF Pitchers:')
|
|
for _, player in hof_pitchers.iterrows():
|
|
print(f' - {player["p_name"]} (ID: {player["player_id"]})')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|