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 <noreply@anthropic.com>
This commit is contained in:
parent
da55cbe4d4
commit
174c485c85
23
helpers.py
23
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'])}",
|
||||
|
||||
@ -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":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user