feat(crafting): add /craft command for duplicate card tier-up (#49) #171
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
autonomous
bug
enhancement
feature
in-queue
performance
security
size:M
size:S
tech-debt
tests
todo
type:feature
type:stability
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#171
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/49-feature-duplicate-card-crafting-tier-up-system"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #49
Summary
Implements the
/craftcommand — combine 2 cards of the same rarity into 1 random card of the next tier up.Craft chain: Replacement → Reserve → Starter → All-Star → MVP → HoF
What's in this PR
cogs/economy_new/crafting.py— newCraftingcog with/craftslash commandpaperdynasty.py— registerscogs.economy_new.craftingin COGS listCommand flow
/craft [rarity]— rarity is optional; if omitted, shows an info embed + 5 rarity buttonsGET /v2/teams/{id}/craft?ts=...&ids={id1},{id2}(same pattern assell/cardsandbuy/players)get_card_embeds()API dependency
This PR requires a new API endpoint on
cal/paper-dynasty-database:Expected behavior:
tshash (same as buy/sell)LIVE_CARDSET_IDExpected response shape:
{"card": { ...card object... }}Other observations
interaction.channel.sendPyright warnings — identical to the same pattern used throughout marketplace.py, economy.py, players.py. Not a new regression.AI Code Review
Files Reviewed
cogs/economy_new/crafting.py(added)paperdynasty.py(modified — cog registration)Findings
Correctness
No issues found.
db_get,team_hash,PD_PLAYERS,get_team_by_owner,get_card_embeds,get_channel,get_team_embed,Confirm,ButtonOptions,SelectViewall confirmed present in their respective modules.send_message+followup.send(rarity=None path) anddefer+followup.send(rarity provided). No double-respond risk.CRAFT_TIER_UPKeyError is not reachable — rarity is constrained to valid dict keys by bothapp_commands.choicesand hardcodedButtonOptionslabels. HoF correctly excluded as a source.new_card = result.get("card", result)handles the expected{"card": {...}}response shape correctly. Defensive fallback is fine.SelectCraftCards.callbackusesedit_message(view=None)correctly to remove the select after submission — prevents re-triggering.min_values=2, max_values=2enforces exactly 2 cards at the Discord protocol level.Security
No issues found.
team_hashauth matches thesell/cardsandbuy/playerspattern exactly — no auth bypass possible.card1_id/card2_idare cast tointfrom select values, then formatted as integers in the query param. Safe.Style & Conventions
No issues found.
marketplace.pyexactly.db_getfor a mutating endpoint is the established project pattern (same as buy/sell).class SelectCraftCards,class Crafting,async def setup) followsmarketplace.pyandscouting.pyconventions."discord_app"is correct.Suggestions
Craft API call uses default 5s timeout.
sell/cardsusestimeout=10, buy/players usestimeout=10. Crafting involves validate + delete 2 cards + create 1 card — considertimeout=10ortimeout=15to reduce false "didn't go through" failures under API load.Stale info embed after rarity button click. When
rarity is None,send_message(embed=embed)posts the info embed. After the user picks a rarity button, the embed stays visible as a stale message. Minor UX inconsistency — considerawait interaction.edit_original_response(content="Fetching your cards...", embed=None)afterquestion.delete(). Not a blocker.SelectView not cleaned up on timeout. After
followup.send(content=..., view=view), if the user ignores the select for 120s, the message is abandoned. Standard pattern in this codebase — not a blocker.Verdict: APPROVED
Clean implementation that follows established project patterns throughout. The crafting tier chain, auth, response handling, and UI flow are all correct. The three suggestions above are non-blocking quality improvements for a follow-up.
Automated review by Claude PR Reviewer
Checkout
From your project repository, check out a new branch and test the changes.