CLAUDE: Update implementation plans for next session

Updated week 6 status and created comprehensive next session plan.

## Changes

### Implementation Status Updates
- Updated 00-index.md with Week 6 progress (75% complete)
- Updated 02-week6-league-features.md status and goals
- Added new components to status table:
  - League Configs:  Complete
  - PlayOutcome Enum:  Complete
  - PlayResolver Integration: 🟡 Partial

### Next Session Plan (NEW)
Created NEXT_SESSION.md with detailed task breakdown:

**Task 1: Update Dice System** (30 min)
- Rename check_d20 → chaos_d20
- Update docstrings for chaos die purpose
- Update all references

**Task 2: Integrate PlayOutcome** (60 min)
- Replace old local enum with universal enum
- Update SimplifiedResultChart
- Add uncapped hit handling
- Update all outcome references

**Task 3: Add Play.metadata** (30 min)
- Add JSONB metadata field to Play model
- Log uncapped hits in metadata
- Update game_engine._save_play_to_db()

## Quick Context for Next Session

**What's Complete**: Config system, PlayOutcome enum, 58 tests passing
**What's Remaining**: Dice system update, PlayResolver integration, metadata support
**Estimated Time**: 2 hours
**Success Criteria**: All tests passing, uncapped hits tracked, terminal client works

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2025-10-28 22:58:56 -05:00
parent 5d5c13f2b8
commit 64aa800672
3 changed files with 260 additions and 13 deletions

View File

@ -68,15 +68,18 @@
| Frontend Foundation | 🔲 Not Started | 1 | Nuxt 3 apps pending |
| Discord OAuth | 🔲 Not Started | 1 | Auth system pending |
| WebSocket Server | 🟡 Partial | 1 | Connection manager exists, handlers pending |
| Game Engine Core | ✅ Complete | 2 | GameEngine with forward-looking snapshots, missing some tests |
| Game Engine Core | ✅ Complete | 2 | GameEngine with forward-looking snapshots |
| Database Schema | ✅ Complete | 2 | All tables created, polymorphic models working |
| Player Models | ✅ Complete | 2 | Polymorphic Lineup & RosterLink for PD/SBA |
| Player Models | ✅ Complete | 2 | BasePlayer, SbaPlayer, PdPlayer with ratings |
| League Configs | ✅ Complete | 2 | SbaConfig, PdConfig with immutable settings (Week 6) |
| PlayOutcome Enum | ✅ Complete | 2 | Universal enum for both leagues (Week 6) |
| PlayResolver Integration | 🟡 Partial | 2 | Needs PlayOutcome migration (Week 6 - 75% done) |
| Strategic Decisions | 🔲 Not Started | 3 | Basic framework exists in decisions models |
| Substitutions | 🔲 Not Started | 3 | Lineup model supports, logic pending |
| AI Opponent | 🔲 Not Started | 3 | - |
| Spectator Mode | 🔲 Not Started | 4 | - |
| UI Polish | 🔲 Not Started | 4 | - |
| Testing Suite | 🟡 Partial | 5 | Unit tests for dice/state, integration tests missing |
| Testing Suite | 🟡 Partial | 5 | 58 config tests + existing core/state tests |
| Deployment | 🔲 Not Started | 5 | - |
## Quick Start
@ -160,9 +163,16 @@ Track important decisions and open questions here as implementation progresses.
- **2025-10-22**: Week 4 complete - State management and persistence working
- **2025-10-24**: Week 5 complete - Game engine core with AbRoll dice system
- **2025-10-25**: GameEngine refactored to forward-looking play tracking pattern
- **2025-10-28**: Week 6 - 75% complete - Config system and PlayOutcome enum implemented
- Both SBA and PD use same card-based resolution mechanics
- Universal PlayOutcome enum with helper methods
- Immutable league configs with singleton registry
- 58 config tests, all passing
---
**Last Updated**: 2025-10-25
**Phase**: Phase 2 - Week 5 Complete (Game Logic)
**Next Milestone**: Phase 2 - Week 6 (League Features & Integration) OR Phase 3 (Complete Game Features)
**Last Updated**: 2025-10-28
**Phase**: Phase 2 - Week 6 (75% Complete)
**Current Work**: League configuration and play outcome system
**Next Session**: Complete Week 6 - dice system update and PlayResolver integration
**Next Milestone**: Phase 3 (Complete Game Features) after Week 6 finished

View File

@ -3,7 +3,9 @@
**Duration**: Week 6 of Phase 2
**Prerequisites**: Week 5 Complete (Game engine working)
**Focus**: League-specific features, configurations, and API integration
**Status**: Planning Complete (2025-10-25)
**Status**: 75% Complete (2025-10-28)
**Last Session**: Config system and PlayOutcome implemented
**Next Session**: Dice system update and PlayResolver integration
---
@ -34,12 +36,13 @@ Complete Phase 2 by implementing:
## Goals
By end of Week 6:
- ✅ Player models (API + Game layers) - **See separate docs**
- ✅ League configuration framework (BaseConfig → SbaConfig/PdConfig)
- ✅ Result chart system for both leagues
- ✅ PlayResolver updated to use configs and PD ratings
- ✅ Complete end-to-end at-bat for both SBA and PD
- ✅ Full test coverage
- ✅ Player models (polymorphic with factory methods) - **COMPLETE 2025-10-28**
- ✅ League configuration framework (BaseConfig → SbaConfig/PdConfig) - **COMPLETE 2025-10-28**
- ✅ PlayOutcome enum (universal for both leagues) - **COMPLETE 2025-10-28**
- ⏳ Dice system update (check_d20 → chaos_d20) - **PENDING**
- ⏳ PlayResolver updated to use PlayOutcome and configs - **PENDING**
- ⏳ Play.metadata support for uncapped hits - **PENDING**
- ⏳ Full test coverage for integration - **PENDING**
## Architecture

View File

@ -0,0 +1,234 @@
# Next Session Plan - Week 6 Completion
**Current Status**: Week 6 - 75% Complete
**Last Commit**: `5d5c13f` - "CLAUDE: Implement Week 6 league configuration and play outcome systems"
**Date**: 2025-10-28
**Remaining Work**: 25% (3 tasks)
---
## Quick Context
### What We Just Completed ✅
1. **League Configuration System**
- `app/config/base_config.py` - Abstract base
- `app/config/league_configs.py` - SBA and PD configs
- Immutable configs with singleton registry
- 28 tests passing
2. **PlayOutcome Enum**
- `app/config/result_charts.py` - Universal outcome enum
- Helper methods: `is_hit()`, `is_out()`, `is_uncapped()`, etc.
- Supports standard hits, uncapped hits, interrupt plays
- 30 tests passing
3. **Player Model Refinements**
- Fixed PdPlayer.id field mapping
- Improved docstrings for image fields
- Fixed position checking in SBA helpers
### Key Architecture Decisions Made
1. **Card-Based Resolution** (Both SBA and PD):
- 1d6 (column: 1-3 batter, 4-6 pitcher)
- 2d6 (row: 2-12 on card)
- 1d20 (split resolution)
- Outcome = PlayOutcome enum value
2. **League Differences**:
- **PD**: Card data digitized (can auto-resolve)
- **SBA**: Physical cards (manual entry only)
3. **Uncapped Hits**:
- `PlayOutcome.SINGLE_UNCAPPED` / `DOUBLE_UNCAPPED`
- Only on pitching cards
- Triggers advancement decision tree when `on_base_code > 0`
---
## Tasks for Next Session
### Task 1: Update Dice System (30 min)
**File**: `backend/app/core/dice.py`
**Changes**:
1. Rename `check_d20``chaos_d20` in `AbRoll` dataclass
2. Update docstring to explain chaos die purpose:
- 5% chance (roll 1) = check wild pitch
- 5% chance (roll 2) = check passed ball
3. Update `DiceSystem.roll_ab()` to use `chaos_d20`
**Files to Update**:
- `app/core/dice.py` - Rename field
- `app/core/roll_types.py` - Update AbRoll dataclass
- `app/core/play_resolver.py` - Use `chaos_d20` instead of `check_d20`
- `tests/unit/core/test_dice.py` - Update test assertions
**Test**: Run `pytest tests/unit/core/test_dice.py -v`
---
### Task 2: Integrate PlayOutcome into PlayResolver (60 min)
**File**: `backend/app/core/play_resolver.py`
**Changes**:
1. **Import new PlayOutcome**:
```python
from app.config import PlayOutcome # Replace old enum
```
2. **Remove old PlayOutcome enum** (lines 22-43):
- Delete the old local enum definition
- Now using universal enum from `app.config`
3. **Update SimplifiedResultChart**:
- Return `PlayOutcome` values (new enum)
- Keep simplified for now (full card resolution in Phase 3)
4. **Add uncapped hit handling**:
```python
def _resolve_outcome(self, outcome: PlayOutcome, state: GameState, ab_roll: AbRoll):
# ... existing code ...
# Handle uncapped hits
if outcome == PlayOutcome.SINGLE_UNCAPPED:
# Log in metadata (Task 3)
# For now, treat as normal single
return self._resolve_single(state, ab_roll, uncapped=True)
```
5. **Update all outcome references**:
- `PlayOutcome.STRIKEOUT` (capital O)
- `PlayOutcome.SINGLE` (not lowercase)
- etc.
**Test**: Run `pytest tests/unit/core/test_play_resolver.py -v`
---
### Task 3: Add Play.metadata Support (30 min)
**Files**:
- `backend/app/models/db_models.py`
- `backend/app/database/operations.py`
- `backend/app/core/game_engine.py`
**Changes**:
1. **Check if Play model already has metadata field**:
```bash
grep -n "metadata" backend/app/models/db_models.py
```
2. **If missing, add to Play model**:
```python
from sqlalchemy.dialects.postgresql import JSONB
class Play(Base):
# ... existing fields ...
metadata = Column(JSONB, default=dict) # Add this
```
3. **Update `game_engine._save_play_to_db()`**:
```python
play_data = {
# ... existing fields ...
"metadata": {} # Add empty dict by default
}
# If uncapped hit
if result.outcome in [PlayOutcome.SINGLE_UNCAPPED, PlayOutcome.DOUBLE_UNCAPPED]:
play_data["metadata"] = {"uncapped": True}
```
4. **Update database operations**:
- `save_play()` to handle metadata field
- Ensure JSONB column works with SQLAlchemy
**Test**:
```bash
pytest tests/integration/test_game_engine.py::test_play_persistence -v
```
---
## Verification Steps
After completing all 3 tasks:
1. **Run all tests**:
```bash
pytest tests/unit/config/ -v
pytest tests/unit/core/ -v
pytest tests/integration/ -v
```
2. **Test with terminal client**:
```bash
python -m terminal_client
> new_game
> defensive normal
> offensive normal
> resolve
```
3. **Check database**:
```sql
SELECT id, outcome, metadata FROM plays LIMIT 5;
```
4. **Commit**:
```bash
git add backend/
git commit -m "CLAUDE: Complete Week 6 - integrate PlayOutcome and add metadata support"
```
---
## Files to Review Before Starting
1. `backend/app/core/dice.py:45-65` - AbRoll dataclass
2. `backend/app/core/play_resolver.py:22-43` - Old PlayOutcome enum (delete)
3. `backend/app/core/play_resolver.py:119-367` - PlayResolver class
4. `backend/app/models/db_models.py` - Play model (check for metadata)
5. `backend/app/core/game_engine.py:520-580` - `_save_play_to_db()` method
---
## Success Criteria
Week 6 will be **100% complete** when:
- ✅ All tests passing (58 config + existing core tests)
- ✅ PlayOutcome enum used throughout PlayResolver
- ✅ Chaos die properly named and documented
- ✅ Uncapped hits logged with metadata
- ✅ Terminal client works with new system
- ✅ Documentation updated
- ✅ Git commit created
---
## Quick Reference
**Current Test Count**: 58 tests (config), ~100+ total
**Last Test Run**: All passing (2025-10-28)
**Branch**: `implement-phase-2`
**Python**: 3.13.3
**Virtual Env**: `backend/venv/`
**Key Imports for Next Session**:
```python
from app.config import get_league_config, PlayOutcome
from app.core.dice import AbRoll
```
---
**Estimated Time**: 2 hours
**Priority**: Medium (completes Week 6 foundation)
**Blocking**: No (can proceed to Phase 3 after, or do in parallel)