Fix double play bug after state recovery #4
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/gameplay-ui-improvements"
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?
ProblemDuring a test game, a Groundball A with 0 outs and runner on first incorrectly resulted in only 1 out (force out at second, batter safe) instead of the expected double play (2 outs).Root Cause: The
current_on_base_codefield was not recalculated during state recovery, defaulting to 0 (empty bases) even when runners were on base. This caused the runner advancement logic to select the wrong result type.## Changes- ✅ Addedcalculate_on_base_code()helper method to GameState model- ✅ Refactored_prepare_next_play()to use helper (eliminates code duplication)- ✅ Fixed state recovery to calculatecurrent_on_base_codefrom actual runner positions- ✅ Fixed X-Check G1 mapping (was GROUNDBALL_B, should be GROUNDBALL_A)- ✅ Added 5 comprehensive regression tests## Testing- All 986 unit tests passing- New regression tests verify fix and demonstrate bug scenario- Tested in network dev environment - double plays now work correctly after game recovery## Files ChangedM backend/app/models/game_models.py (+27 lines)M backend/app/core/game_engine.py (-6 lines)M backend/app/core/state_manager.py (+6 lines)M backend/app/core/play_resolver.py (+1 line)A backend/tests/unit/core/test_recovery_double_play_fix.pyA BUGFIX_DOUBLE_PLAY_RECOVERY.md## ImpactFixes a critical gameplay bug where double plays would not work after rejoining a game.---🤖 Generated with Claude Code