feat: Uncapped hit decision tree, x-check workflow, baserunner UI #8

Merged
cal merged 11 commits from feature/uncapped-hit-decision-tree into main 2026-02-12 15:37:34 +00:00

11 Commits

Author SHA1 Message Date
Cal Corum
529c5b1b99 CLAUDE: Implement uncapped hit interactive decision tree (Issue #6)
Add full multi-step decision workflow for SINGLE_UNCAPPED and DOUBLE_UNCAPPED
outcomes, replacing the previous stub that fell through to basic single/double
advancement. The decision tree follows the same interactive pattern as X-Check
resolution with 5 phases: lead runner advance, defensive throw, trail runner
advance, throw target selection, and safe/out speed check.

- game_models.py: PendingUncappedHit model, 5 new decision phases
- game_engine.py: initiate_uncapped_hit(), 5 submit methods, 3 result builders
- handlers.py: 5 new WebSocket event handlers
- ai_opponent.py: 5 AI decision stubs (conservative defaults)
- play_resolver.py: Updated TODO comments for fallback paths
- 80 new backend tests (2481 total): workflow (49), handlers (23), truth tables (8)
- Fix GameplayPanel.spec.ts: add missing Pinia setup, fix component references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 09:33:58 -06:00
Cal Corum
2a70df74bf CLAUDE: Fix on_base_code encoding bug + add truth table & invariant tests
Fix critical encoding mismatch where calculate_on_base_code() returned
bit-field encoding (3=R1+R2, 4=R3) but runner_advancement.py charts
expected sequential encoding (3=R3, 4=R1+R2). Values 3 and 4 were
swapped, causing wrong groundball results for R1+R2 and R3-only scenarios.

Add comprehensive test coverage:
- 1184 invariant tests (structural correctness across all outcomes × base codes)
- 49 hit truth table tests (SINGLE_1/2, DOUBLE_2/3, TRIPLE, HOMERUN)
- 33 walk truth table tests (WALK, HBP with stat flag verification)
- 42 simple out truth table tests (STRIKEOUT, LINEOUT, POPOUT, WP, PB)
- 88 groundball truth table tests (GB_A/B/C × infield back/in/corners_in × locations)

Total: 2401 unit tests passing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 23:33:10 -06:00
Cal Corum
7c54bfd26b CLAUDE: Improve hold runner button - fixed width, two-column NOT|HELD display, remove redundant section 2026-02-08 11:06:25 -06:00
Cal Corum
46caf9cd81 CLAUDE: Update color scheme - red for runners, blue for catcher
Runner highlights and cards:
- Pills: red-500 ring, red-50 background when selected
- Full cards: red gradient (red-900 to red-950), red-600 border
- Pulse glow: red animation (rgba(239, 68, 68))
- Hardcoded red color (#ef4444) for runner pill borders

Catcher highlights and cards:
- Pill: blue-500 ring, blue-50 background when selected
- Full card: blue gradient (blue-900 to blue-950), blue-600 border
- Pulse glow: blue animation (rgba(59, 130, 246))

Updated tests to expect new colors

All 15 RunnersOnBase tests passing
All 16 RunnerCard tests passing
2026-02-07 23:50:24 -06:00
Cal Corum
6b86afe5e4 CLAUDE: Show lead runner + catcher when catcher is selected
- When catcher pill is clicked, display lead runner (3B > 2B > 1B priority) + catcher side-by-side
- Maintains consistent layout whether runner or catcher is selected
- Add leadRunnerBase computed to find highest priority runner
- Add displayedRunnerBase computed to show selected OR lead runner
- Update template to use displayedRunnerPlayer for consistent rendering

All 15 RunnersOnBase tests passing
2026-02-07 23:45:19 -06:00
Cal Corum
d6ea5104d6 CLAUDE: Enhance baserunner panel with lead runner auto-select and clickable catcher
- Swap base order to 3B, 2B, 1B (left to right, closer to baseball diamond)
- Auto-select lead runner on mount (priority: 3B > 2B > 1B)
- Make catcher pill clickable to show catcher card only
- Add 'catcher' as a selection option alongside runner bases
- Update expanded view to handle catcher-only display (centered, single card)
- Add toggleCatcher() function
- Update tests for new base order and auto-selection behavior

All 15 RunnersOnBase tests passing
All 16 RunnerCard tests passing
2026-02-07 23:42:25 -06:00
Cal Corum
5118335020 CLAUDE: Update RunnersOnBase tests for new horizontal layout
- Replace .border-l-4.border-gray-600 checks with .catcher-pill
- Update isExpanded prop references to isSelected
- Adjust expanded view tests for new side-by-side layout
  - matchup-card-blue = runner full card
  - matchup-card = catcher full card
- Fix deselection test to check isSelected prop (Transition keeps DOM during animation)

All 15 RunnersOnBase tests passing
All 16 RunnerCard tests passing
2026-02-07 23:36:07 -06:00
Cal Corum
453280487c CLAUDE: Integrate XCheckWizard into GameplayPanel and wire up WebSocket/store
Step 7 of x-check interactive workflow implementation:

Frontend Integration:
- GameplayPanel.vue: Add x_check_result_pending workflow state, show XCheckWizard when decision_phase is awaiting_x_check_result, handle interactive vs read-only mode based on active_team_id
- store/game.ts: Add xCheckData and decideData state, add needsXCheckResult/needsDecide* getters, add set/clear actions for x-check and decide data
- useWebSocket.ts: Handle decision_required events with x_check_result/decide_advance/decide_throw/decide_speed_check types, route to appropriate store actions, clear x-check/decide data on play_resolved
- useGameActions.ts: Add submitXCheckResult(), submitDecideAdvance(), submitDecideThrow(), submitDecideResult() action wrappers
- types: Export XCheckData, DecideAdvanceData, DecideThrowData, DecideSpeedCheckData, PendingXCheck, and new WebSocket request types

Type fixes:
- XCheckData: Allow readonly arrays for d6_individual and chart_row (store returns readonly refs)
- GameplayPanel: Add userTeamId prop for determining interactive mode

Tests: 460 passing, 28 failing (GameplayPanel.spec.ts needs Pinia setup - pre-existing issue)

Next: Step 8 - End-to-end testing of basic x-check flow (no DECIDE)
2026-02-07 17:43:17 -06:00
Cal Corum
f77666db87 CLAUDE: Add XCheckWizard component and result constants (step 6)
New files:
- constants/xCheckResults.ts - Labels, helpers for all result codes
- components/Gameplay/XCheckWizard.vue - Interactive x-check UI

XCheckWizard features:
 Displays d20 and 3d6 dice results prominently
 Shows 5-column chart row (Range 1-5) as selectable buttons
 Hash result sub-choices (G2#/G3# → pick G2 or SI2)
 SPD result sub-choice (click to reveal d20, pick safe/out)
 Error selection (NO/E1/E2/E3/RP) based on 3d6
 Submit validation (both result + error required)
 Read-only mode for transparency (opponent sees same UI)
 Mobile-responsive layout (stacks on small screens)
 Tailwind styling with clear visual hierarchy

Helper functions:
- getResultLabel() - Display names for all codes
- getErrorLabel() - Display names for error types
- isHashResult() - Detect G2#/G3#
- isSpdResult() - Detect SPD
- getHashConversions() - Get conversion options

Next: Integrate XCheckWizard into GameplayPanel

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 17:36:23 -06:00
Cal Corum
160550afca CLAUDE: Add comprehensive unit tests for PendingXCheck model
Test coverage:
- Creation with minimal fields (required only)
- Creation with optional fields (SPD, result selection, DECIDE)
- Field validation (d20, d6, chart_row, error_result, etc.)
- Range constraints (d20: 1-20, d6: 1-6, bases: proper values)
- Mutability during workflow (can update selections)

Results:
- 19 new tests, all passing
- Total: 1005 unit tests passing (was 986)
- PendingXCheck model fully validated

Next: Create XCheckWizard frontend component

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 17:30:19 -06:00
Cal Corum
defa06653d CLAUDE: Add interactive x-check workflow foundation (steps 1-5)
Backend changes:
- Add PendingXCheck model for interactive x-check state
- Extend decision_phase/pending_decision validators with 4 new phases
- Add initiate_x_check() to roll dice and present chart to player
- Add submit_x_check_result() to process player selection
- Add resolve_x_check_from_selection() to resolve from player input
- Add WebSocket handlers for x-check workflow
- Modify resolve_manual_play() to route X_CHECK to interactive flow
- All 986 unit tests passing

Frontend changes:
- Extend DecisionPhase type with x-check/DECIDE phases
- Add XCheckData, DecideAdvanceData, DecideThrowData, DecideSpeedCheckData interfaces
- Add PendingXCheck to GameState
- Add 4 new client→server WebSocket events

Next: Implement XCheckWizard component and GameplayPanel integration

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 17:21:19 -06:00