3ef8d329f8
3 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a4b99ee53e |
CLAUDE: Replace black and flake8 with ruff for formatting and linting
Migrated to ruff for faster, modern code formatting and linting: Configuration changes: - pyproject.toml: Added ruff 0.8.6, removed black/flake8 - Configured ruff with black-compatible formatting (88 chars) - Enabled comprehensive linting rules (pycodestyle, pyflakes, isort, pyupgrade, bugbear, comprehensions, simplify, return) - Updated CLAUDE.md: Changed code quality commands to use ruff Code improvements (490 auto-fixes): - Modernized type hints: List[T] → list[T], Dict[K,V] → dict[K,V], Optional[T] → T | None - Sorted all imports (isort integration) - Removed unused imports - Fixed whitespace issues - Reformatted 38 files for consistency Bug fixes: - app/core/play_resolver.py: Fixed type hint bug (any → Any) - tests/unit/core/test_runner_advancement.py: Removed obsolete random mock Testing: - All 739 unit tests passing (100%) - No regressions introduced 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|
|
efd38d2580 |
CLAUDE: Phase 3F - Substitution System Testing Complete
Completed final 20% of substitution system with comprehensive test coverage. All 640 unit tests passing (100%). Phase 3 now 100% complete. ## Unit Tests (31 tests) - NEW tests/unit/core/test_substitution_rules.py: - TestPinchHitterValidation: 6 tests * Success case * NOT_CURRENT_BATTER validation * PLAYER_ALREADY_OUT validation * NOT_IN_ROSTER validation * ALREADY_ACTIVE validation * Bench player edge case - TestDefensiveReplacementValidation: 9 tests * Success case * Position change allowed * PLAYER_ALREADY_OUT validation * NOT_IN_ROSTER validation * ALREADY_ACTIVE validation * INVALID_POSITION validation * All valid positions (P, C, 1B-3B, SS, LF-RF, DH) * Mid-inning warning logged * allow_mid_inning flag works - TestPitchingChangeValidation: 7 tests * Success case (after min batters) * PLAYER_ALREADY_OUT validation * NOT_A_PITCHER validation * MIN_BATTERS_NOT_MET validation * force_change bypasses min batters * NOT_IN_ROSTER validation * ALREADY_ACTIVE validation - TestDoubleSwitchValidation: 6 tests * Success case with batting order swap * First substitution invalid * Second substitution invalid * INVALID_BATTING_ORDER validation * DUPLICATE_BATTING_ORDER validation * All valid batting order combinations (1-9) - TestValidationResultDataclass: 3 tests * Valid result creation * Invalid result with error * Result with message only ## Integration Tests (10 tests) - NEW tests/integration/test_substitution_manager.py: - TestPinchHitIntegration: 2 tests * Full flow: validation → DB → state sync * Validation failure (ALREADY_ACTIVE) - TestDefensiveReplacementIntegration: 2 tests * Full flow with DB/state verification * Position change (SS → 2B) - TestPitchingChangeIntegration: 3 tests * Full flow with current_pitcher update * MIN_BATTERS_NOT_MET validation * force_change emergency bypass - TestSubstitutionStateSync: 3 tests * Multiple substitutions stay synced * Batting order preserved after substitution * State cache matches database Fixtures: - game_with_lineups: Creates game with 9 active + 3 bench players - Proper async session management - Database cleanup handled ## Bug Fixes app/core/substitution_rules.py: - Fixed to use new GameState structure - Changed: state.current_batter_lineup_id → state.current_batter.lineup_id - Aligns with Phase 3E GameState refactoring ## Test Results Unit Tests: - 640/640 passing (100%) - 31 new substitution tests - All edge cases covered - Execution: 1.02s Integration Tests: - 10 tests implemented - Full DB + state sync verification - Note: Run individually due to known asyncpg connection issues ## Documentation Updates .claude/implementation/NEXT_SESSION.md: - Updated Phase 3 progress to 100% complete - Marked Task 2 (unit tests) completed - Marked Task 3 (integration tests) completed - Updated success criteria with completion notes - Documented test counts and coverage ## Phase 3 Status: 100% COMPLETE ✅ - Phase 3A-D (X-Check Core): 100% - Phase 3E-Prep (GameState Refactor): 100% - Phase 3E-Main (Position Ratings): 100% - Phase 3E-Final (Redis/WebSocket): 100% - Phase 3E Testing (Terminal Client): 100% - Phase 3F (Substitutions): 100% All core gameplay features implemented and fully tested. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|
|
d1619b4a1f |
CLAUDE: Phase 3 - Substitution System Core Logic
Implemented comprehensive substitution system with DB-first pattern: ## Core Components (1,027 lines) 1. SubstitutionRules (345 lines) - Validates pinch hitter, defensive replacement, pitching change - Enforces no re-entry, roster eligibility, active status - Comprehensive error messages with error codes 2. SubstitutionManager (552 lines) - Orchestrates DB-first pattern: validate → DB → state - Handles pinch_hit, defensive_replace, change_pitcher - Automatic state sync and lineup cache updates 3. Database Operations (+115 lines) - create_substitution(): Creates sub with full metadata - get_eligible_substitutes(): Lists inactive players 4. Model Enhancements (+15 lines) - Added get_player_by_card_id() to TeamLineupState ## Key Features - ✅ DB-first pattern (database is source of truth) - ✅ Immutable lineup history (audit trail) - ✅ Comprehensive validation (8+ rule checks) - ✅ State + DB sync guaranteed - ✅ Error handling at every step - ✅ Detailed logging for debugging ## Architecture Decisions - Position flexibility (MVP - no eligibility check) - Batting order inheritance (pinch hitter takes spot) - No re-entry (matches real baseball rules) - Validation uses in-memory state (fast) ## Remaining Work - WebSocket event handlers (2-3 hours) - Comprehensive testing (2-3 hours) - API documentation (1 hour) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |