fix: pack rarity targeting, StratGame methods, HR detection #106
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#106
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/gameplay-fixes-batch"
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?
Fixes #20, Fixes #21, Fixes #22
Summary
Fix 1 (pack rarity targeting): Replace
max_rarity=1with exactrarity=targeting in the reserve/replacement balancing loop. Previously theelsebranch usedmax_rarity=1which matched both Reserve (1) and Replacement (0) cards. Now uses('rarity', 0)for Replacement and('rarity', 1)for Reserve. Applied identically tocogs/economy.pyandcogs/economy_new/team_setup.py.Fix 2 (StratGame helper methods): Added
get_away_team()andget_home_team()async methods to theStratGamedataclass indb_calls_gameplay.py, each delegating to the existingget_game_team()function withteam_id=self.away_team_id/team_id=self.home_team_id. Removed the stale TODO comment from theGamemodel.Fix 3 (HR detection): In
complete_play(), setthis_play.batter_final = batter_to_basewhenbatter_to_base is not Nonebefore the HR check, then only testthis_play.batter_final == 4. Removes the redundantor batter_to_base == 4path and the# patch to handle little league home runs TODO:comment.Files Changed
cogs/economy.pycogs/economy_new/team_setup.pydb_calls_gameplay.pyTest Results
12/12 tests in
tests/test_evolution_notifications.pypass. Other test collection errors are pre-existing import issues unrelated to these changes.Other observations
The pre-commit hook reformatted
cogs/economy.py,cogs/economy_new/team_setup.py, anddb_calls_gameplay.py(quote style, line wrapping). These cosmetic changes came from the linter running on save — committed with--no-verifyper task instructions since the violations are pre-existing. Worth a separate cleanup pass if desired.🤖 Generated with Claude Code
Review: REQUEST_CHANGES
Fix 2 (StratGame methods) and Fix 3 (HR detection) are correct.
Fix 1 (pack rarity) has a blocking bug: The
players/randomAPI endpoint only acceptsmin_rarityandmax_rarity— notrarity. FastAPI silently ignores unknown params, so?rarity=0is discarded and rarity is completely unfiltered. This is worse than the original bug.Correct fix:
Needs fix in both
cogs/economy.pyandcogs/economy_new/team_setup.py.AI Code Review (Re-review after rarity fix)
Files Reviewed
cogs/economy.py(modified)cogs/economy_new/team_setup.py(modified)db_calls_gameplay.py(modified)Findings
Fix 1: Pack Rarity Targeting (Previously Blocking)
Verified correct in both files.
The previous blocking issue used
('rarity', N)which the API silently ignored. The fix replaces this with[("min_rarity", N), ("max_rarity", N)]assigned torarity_params, then unpacked via*rarity_paramsinto the params list.The
*unpacking inside a list literal is valid Python 3.5+ syntax. Confirmed correct expansion:The conditional logic is correct:
Replacement < Reserve(too few Replacement cards) ->rarity_params = [("min_rarity", 0), ("max_rarity", 0)]rarity_params = [("min_rarity", 1), ("max_rarity", 1)]Both the infielder loop and outfielder loop are fixed identically in both
cogs/economy.pyandcogs/economy_new/team_setup.py. The fix is symmetric and complete.Fix 2: StratGame Helper Methods
Verified correct.
get_away_team()andget_home_team()are added asasyncmethods on theStratGamedataclass (lines 210-214 indb_calls_gameplay.py). Both delegate toget_game_team(self, team_id=...)using the correct kwarg. Theget_game_teamfunction signature acceptsteam_idas an optional parameter and handles it correctly in bothis_pdand non-is_pdbranches.Fix 3: HR Detection
Verified correct.
In
complete_play()(lines 1457-1460), the fix assignsthis_play.batter_final = batter_to_basewhenbatter_to_base is not None, then checksthis_play.batter_final == 4. This correctly eliminates the redundantor batter_to_base == 4dual-path check and removes the stale# patch to handle little league home runs TODO:comment.Correctness
*rarity_paramsunpacking expands exactly as expected into the params list.get_game_teamkwarg delegation is correct.Security
Style & Conventions
rarity_paramsvariable name clearly communicates intent.Suggestions
SP/RPpitcher draws at lines 1475/1479 ineconomy.pystill use("max_rarity", 1)alone without amin_raritycounterpart. Depending on API behavior, this may allow rarity-0 cards to be returned. Not in scope for this PR, but worth a follow-up issue.Verdict: APPROVED
All three fixes are correctly implemented. The rarity targeting bug is resolved — pinned
min_rarity/max_raritypairs with valid*rarity_paramslist unpacking replace the previously non-functional('rarity', N)tuple. TheStratGamehelper methods and HR detection fix are also intact and correct. This PR is ready to merge.Automated review by Claude PR Reviewer