strat-gameplay-webapp/backend/app
Cal Corum 13e924a87c CLAUDE: Refactor GameEngine to forward-looking play tracking pattern
Replaced awkward "lookback" pattern with clean "prepare → execute → save"
orchestration that captures state snapshots BEFORE each play.

Key improvements:
- Added per-team batter indices (away_team_batter_idx, home_team_batter_idx)
- Added play snapshot fields (current_batter/pitcher/catcher_lineup_id)
- Added on_base_code bit field for efficient base situation queries
- Created _prepare_next_play() method for snapshot preparation
- Refactored start_game() with hard lineup validation requirement
- Refactored resolve_play() with explicit 6-step orchestration
- Updated _save_play_to_db() to use snapshots (no DB lookbacks)
- Enhanced state recovery to rebuild from last play (single query)
- Added defensive lineup position validator

Benefits:
- No special cases for first play
- Single source of truth in GameState
- Saves 18+ database queries per game
- Fast state recovery without replay
- Complete runner tracking (before/after positions)
- Explicit orchestration (easy to debug)

Testing:
- Added 3 new test functions (lineup validation, snapshot tracking, batting order)
- All 5 test suites passing (100%)
- Type checking cleaned up with targeted suppressions for SQLAlchemy

Documentation:
- Added comprehensive "Type Checking & Common False Positives" section to CLAUDE.md
- Created type-checking-guide.md and type-checking-summary.md
- Added mypy.ini configuration for SQLAlchemy/Pydantic

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 22:18:15 -05:00
..
api CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00
core CLAUDE: Refactor GameEngine to forward-looking play tracking pattern 2025-10-25 22:18:15 -05:00
database CLAUDE: Implement comprehensive dice roll system with persistence 2025-10-24 08:29:02 -05:00
models CLAUDE: Refactor GameEngine to forward-looking play tracking pattern 2025-10-25 22:18:15 -05:00
utils CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00
websocket CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00
__init__.py CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00
config.py CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00
main.py CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00