fix: use exact rarity targeting for reserve/replacement in pack distribution (#20) #66
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#66
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-discord-20"
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?
Summary
elsebranch of the reserve/replacement balancing check usedmax_rarity=1, which allows cards of rarity 0 (Replacement) or 1 (Reserve). When trying to specifically draw a Reserve card, this was incorrect — the API needs bothmin_rarityandmax_rarityset to the same value to target an exact tier.max_rar = 1/if ... max_rar = 0pattern withrar = RARITY['Replacement'] if ... else RARITY['Reserve'], then passed('min_rarity', rar), ('max_rarity', rar)toplayers/randomin both the infielder and outfielder loops.RARITYto the import incogs/economy_new/team_setup.pyand removed the TODO comments.Files changed
cogs/economy.py— fixed infielder and outfielder loopscogs/economy_new/team_setup.py— addedRARITYimport, fixed infielder and outfielder loopsTest results
No test suite for this area. Changes verified by reading back all four modified loops.
Other observations
cogs/economy_new/team_setup.pywas already reformatted by ruff before my edit (pre-existing, not caused by this PR).five_sps,five_rps) intentionally usemax_rarity=1as an initialization step before any balancing — these were not changed as they are outside the scope of the TODO.AI Code Review
Files Reviewed
cogs/economy.py(modified — infielder + outfielder reserve/replacement loops)cogs/economy_new/team_setup.py(modified — same loops + RARITY import added)Findings
Correctness
max_rarity=1when targeting a Reserve card (rarity=1) silently allowed Replacement (0) OR Reserve (1) to be returned. New code usesmin_rarity=rar, max_rarity=rarfor exact tier targeting.RARITYvalues confirmed:Reserve=1,Replacement=0.roster_counts["Replacement"] < roster_counts["Reserve"]→ draw Replacement, else draw Reserve matches the original TODO comment exactly.none_okay=Falsepreserved on all fourdb_getcalls — errors still surface correctly.five_sps,five_rps) correctly left withmax_rarity=1only — these are initialization seeds, not balance draws. Out of scope for this fix.Security
Style & Conventions
RARITYadded to existingfrom helpers.constants import ...inteam_setup.py— correct explicit import pattern.economy.py,RARITYis available viafrom helpers import *— no additional import needed. ✓Suggestions
five_sps/five_rps) also usemax_rarity=1withoutmin_rarity, which means they can return Replacement-tier pitchers. That's a separate concern and correctly identified as out of scope here.Verdict: COMMENT
Fix is correct and minimal in scope. Gitea blocks self-approval, posting as COMMENT.
Automated review by Claude PR Reviewer
7ec0fc835bto26b0e8395fClosing — will re-implement fresh against
main. Original PR had unrebaseable conflicts from the scouting refactor.Pull request closed