Cal Corum
9245b4e008
CLAUDE: Implement Week 7 Task 3 - Result chart abstraction and PD auto mode
...
Core Implementation:
- Added ResultChart abstract base class with get_outcome() method
- Implemented calculate_hit_location() helper for hit distribution
- 45% pull, 35% center, 20% opposite field
- RHB pulls left, LHB pulls right
- Groundballs → infield positions, flyouts → outfield positions
- Added PlayOutcome.requires_hit_location() helper method
- Returns True for groundballs and flyouts only
Manual Mode Support:
- Added ManualResultChart (passthrough for interface completeness)
- Manual mode doesn't use result charts - players submit directly
- Added ManualOutcomeSubmission model for WebSocket submissions
- Validates PlayOutcome enum values
- Validates hit location positions (1B, 2B, SS, 3B, LF, CF, RF, P, C)
PD Auto Mode Implementation:
- Implemented PdAutoResultChart for automated outcome generation
- Coin flip (50/50) to choose batting or pitching card
- Gets rating for correct handedness matchup
- Builds cumulative distribution from rating percentages
- Rolls 1d100 to select outcome
- Calculates hit location using handedness and pull rates
- Maps rating fields to PlayOutcome enum:
- Common: homerun, triple, doubles, singles, walks, strikeouts
- Batting-specific: lineouts, popouts, flyout variants, groundout variants
- Pitching-specific: uncapped singles/doubles, flyouts by location
- Proper error handling when card data missing
Testing:
- Created 21 comprehensive unit tests (all passing)
- Helper function tests (calculate_hit_location)
- PlayOutcome helper tests (requires_hit_location)
- ManualResultChart tests (NotImplementedError)
- PdAutoResultChart tests:
- Coin flip distribution (~50/50)
- Handedness matchup selection
- Cumulative distribution building
- Outcome selection from probabilities
- Hit location calculation
- Error handling for missing cards
- Statistical distribution verification (1000 trials)
- ManualOutcomeSubmission validation tests
- Valid/invalid outcomes
- Valid/invalid hit locations
- Optional location handling
Deferred to Future Tasks:
- PlayResolver integration (Phase 6 - Week 7 Task 3B)
- Terminal client manual outcome command (Phase 8)
- WebSocket handlers for manual submissions (Week 7 Task 6)
- Runner advancement logic using hit locations (Week 7 Task 4)
Files Modified:
- app/config/result_charts.py: Added base class, auto mode, and helpers
- app/models/game_models.py: Added ManualOutcomeSubmission model
- tests/unit/config/test_result_charts.py: 21 comprehensive tests
All tests passing, no regressions.
2025-10-30 12:42:41 -05:00
Cal Corum
6880b6d5ad
CLAUDE: Complete Week 6 - granular PlayOutcome integration and metadata support
...
- Renamed check_d20 → chaos_d20 throughout dice system
- Expanded PlayOutcome enum with granular variants (SINGLE_1/2, DOUBLE_2/3, GROUNDBALL_A/B/C, etc.)
- Integrated PlayOutcome from app.config into PlayResolver
- Added play_metadata support for uncapped hit tracking
- Updated all tests (139/140 passing)
Week 6: 100% Complete - Ready for Phase 3
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 20:29:06 -05:00
Cal Corum
5d5c13f2b8
CLAUDE: Implement Week 6 league configuration and play outcome systems
...
Week 6 Progress: 75% Complete
## Components Implemented
### 1. League Configuration System ✅
- Created BaseGameConfig abstract class for league-agnostic rules
- Implemented SbaConfig and PdConfig with league-specific settings
- Immutable configs (frozen=True) with singleton registry
- 28 unit tests, all passing
Files:
- backend/app/config/base_config.py
- backend/app/config/league_configs.py
- backend/tests/unit/config/test_league_configs.py
### 2. PlayOutcome Enum ✅
- Universal enum for all play outcomes (both SBA and PD)
- Helper methods: is_hit(), is_out(), is_uncapped(), is_interrupt()
- Supports standard hits, uncapped hits, interrupt plays, ballpark power
- 30 unit tests, all passing
Files:
- backend/app/config/result_charts.py
- backend/tests/unit/config/test_play_outcome.py
### 3. Player Model Refinements ✅
- Fixed PdPlayer.id field mapping (player_id → id)
- Improved field docstrings for image types
- Fixed position checking logic in SBA helper methods
- Added safety checks for missing image data
Files:
- backend/app/models/player_models.py (updated)
### 4. Documentation ✅
- Updated backend/CLAUDE.md with Week 6 section
- Documented card-based resolution mechanics
- Detailed config system and PlayOutcome usage
## Architecture Decisions
1. **Card-Based Resolution**: Both SBA and PD use same mechanics
- 1d6 (column) + 2d6 (row) + 1d20 (split resolution)
- PD: Digitized cards with auto-resolution
- SBA: Manual entry from physical cards
2. **Immutable Configs**: Prevent accidental modification using Pydantic frozen
3. **Universal PlayOutcome**: Single enum for both leagues reduces duplication
## Testing
- Total: 58 tests, all passing
- Config tests: 28
- PlayOutcome tests: 30
## Remaining Work (25%)
- Update dice system (check_d20 → chaos_d20)
- Integrate PlayOutcome into PlayResolver
- Add Play.metadata support for uncapped hits
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 22:46:12 -05:00