From 174c485c85f602a2c1e6c822f0e9914db6958638 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Thu, 5 Mar 2026 15:35:19 -0600 Subject: [PATCH] fix: implement paperdex dupe-detection logic (#23) Queries cards API by player_id + team_id to count copies owned, displays dupe count in card embed for non-Paper-Dynasty teams. Co-Authored-By: Claude Sonnet 4.6 --- helpers.py | 23 +++++++++++++++-------- helpers/main.py | 17 ++++++++++++----- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/helpers.py b/helpers.py index 9485437..50e3571 100644 --- a/helpers.py +++ b/helpers.py @@ -177,11 +177,18 @@ async def get_card_embeds(card, include_stats=False) -> list: name="Collected By", value=f"{count} team{'s' if count != 1 else ''}" ) - # TODO: check for dupes with the included paperdex data - # if card['team']['lname'] != 'Paper Dynasty': - # team_dex = await db_get('cards', params=[("player_id", card["player"]["player_id"]), ('team_id', card['team']['id'])]) - # count = 1 if not team_dex['count'] else team_dex['count'] - # embed.add_field(name='# Dupes', value=f'{count - 1} dupe{"s" if count - 1 != 1 else ""}') + if card["team"]["lname"] != "Paper Dynasty": + team_dex = await db_get( + "cards", + params=[ + ("player_id", card["player"]["player_id"]), + ("team_id", card["team"]["id"]), + ], + ) + dupe_count = 0 if not team_dex["count"] else team_dex["count"] - 1 + embed.add_field( + name="# Dupes", value=f'{dupe_count} dupe{"s" if dupe_count != 1 else ""}' + ) # embed.add_field(name='Team', value=f'{card["player"]["mlbclub"]}') if card["player"]["franchise"] != "Pokemon": @@ -1682,9 +1689,9 @@ async def paperdex_team_embed(team: dict, mlb_team: dict) -> list[discord.Embed] for cardset_id in coll_data: if cardset_id != "total_owned": if coll_data[cardset_id]["players"]: - coll_data[cardset_id]["embeds"][0].description = ( - f"{mlb_team['lname']} / {coll_data[cardset_id]['name']}" - ) + coll_data[cardset_id]["embeds"][ + 0 + ].description = f"{mlb_team['lname']} / {coll_data[cardset_id]['name']}" coll_data[cardset_id]["embeds"][0].add_field( name="# Collected / # Total Cards", value=f"{coll_data[cardset_id]['owned']} / {len(coll_data[cardset_id]['players'])}", diff --git a/helpers/main.py b/helpers/main.py index 0b989a5..e8b008a 100644 --- a/helpers/main.py +++ b/helpers/main.py @@ -181,11 +181,18 @@ async def get_card_embeds(card, include_stats=False) -> list: name="Collected By", value=f"{count} team{'s' if count != 1 else ''}" ) - # TODO: check for dupes with the included paperdex data - # if card['team']['lname'] != 'Paper Dynasty': - # team_dex = await db_get('cards', params=[("player_id", card["player"]["player_id"]), ('team_id', card['team']['id'])]) - # count = 1 if not team_dex['count'] else team_dex['count'] - # embed.add_field(name='# Dupes', value=f'{count - 1} dupe{"s" if count - 1 != 1 else ""}') + if card["team"]["lname"] != "Paper Dynasty": + team_dex = await db_get( + "cards", + params=[ + ("player_id", card["player"]["player_id"]), + ("team_id", card["team"]["id"]), + ], + ) + dupe_count = 0 if not team_dex["count"] else team_dex["count"] - 1 + embed.add_field( + name="# Dupes", value=f'{dupe_count} dupe{"s" if dupe_count != 1 else ""}' + ) # embed.add_field(name='Team', value=f'{card["player"]["mlbclub"]}') if card["player"]["franchise"] != "Pokemon":