strat-gameplay-webapp/backend/tests/unit/core
Cal Corum dd1b087af1 CLAUDE: Fix double play bug after state recovery
Critical bug fix for issue where Groundball A with runner on first would
fail to execute a double play after game recovery from database.

Root cause: current_on_base_code field was not recalculated during state
recovery, defaulting to 0 (empty bases) even when runners were on base.
This caused runner advancement logic to select Result 1 (batter out,
runners hold) instead of Result 2 (double play).

Changes:
- Added calculate_on_base_code() helper method to GameState model
- Updated _prepare_next_play() to use helper (eliminates duplication)
- Fixed state recovery to calculate current_on_base_code from runners
- Fixed X-Check G1 mapping (was GROUNDBALL_B, should be GROUNDBALL_A)
- Added 5 regression tests to prevent recurrence

Testing:
- All 359 unit tests passing
- New regression tests verify fix and demonstrate bug scenario
- Tested in network dev environment - double plays now work correctly

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 13:55:10 -06:00
..
__init__.py CLAUDE: Complete Week 4 - State Management & Persistence 2025-10-22 12:01:03 -05:00
test_dice.py CLAUDE: Fix all unit test failures and implement 100% test requirement 2025-11-04 19:35:21 -06:00
test_exceptions.py CLAUDE: Add exception tests and enhance stop-services script 2025-11-28 12:10:59 -06:00
test_flyball_advancement.py CLAUDE: Fix state recovery batter advancement and flyball descriptions 2025-11-21 15:38:29 -06:00
test_game_eviction.py CLAUDE: Add game state eviction and resource management 2025-11-28 12:07:55 -06:00
test_play_resolver.py CLAUDE: Add game state eviction and resource management 2025-11-28 12:07:55 -06:00
test_recovery_double_play_fix.py CLAUDE: Fix double play bug after state recovery 2026-02-07 13:55:10 -06:00
test_roll_types.py CLAUDE: Complete Week 6 - granular PlayOutcome integration and metadata support 2025-10-29 20:29:06 -05:00
test_runner_advancement.py CLAUDE: Replace black and flake8 with ruff for formatting and linting 2025-11-20 15:33:21 -06:00
test_state_manager.py CLAUDE: Add game state eviction and resource management 2025-11-28 12:07:55 -06:00
test_substitution_rules.py CLAUDE: Phase 3F - Substitution System Testing Complete 2025-11-04 22:34:17 -06:00
test_validators.py CLAUDE: Fix squeeze_bunt validation - remove bases loaded restriction 2025-11-14 15:09:03 -06:00
test_x_check_advancement_tables.py CLAUDE: Fix all unit test failures and implement 100% test requirement 2025-11-04 19:35:21 -06:00