Skip to content

Conversation

@edloidas
Copy link
Owner

@edloidas edloidas commented Jan 5, 2026

Add the evaluator module that transforms parsed AST into roll results:

Core Implementation:

  • Add RollResult and DieResult types in src/types.ts
  • Implement keep/drop modifiers (kh, kl, dh, dl)
  • Implement recursive AST evaluation with RNG injection
  • Track critical/fumble detection on individual dice
  • Ensure negative results are NOT clamped (1d4-5 = -4)

Parser Bug Fix:

  • Fix modifier chaining: 4d6dl1kh3 now parses as (4d6dl1)kh3
  • Change binding power from BP.MODIFIER to BP.DICE_LEFT
  • Prevents modifiers in count position while allowing computed counts
  • Satisfies PRD requirement for modifier chaining (line 478)

Tests:

  • 37 evaluator unit tests (using MockRNG for determinism)
  • 5 parser tests for modifier chaining
  • Total: 186 tests passing (all green)

Documentation:

Validation: All checks pass (typecheck, lint, format, build, test)

🤖 Generated with Claude Code

Add the evaluator module that transforms parsed AST into roll results:

**Core Implementation**:
- Add RollResult and DieResult types in src/types.ts
- Implement keep/drop modifiers (kh, kl, dh, dl)
- Implement recursive AST evaluation with RNG injection
- Track critical/fumble detection on individual dice
- Ensure negative results are NOT clamped (1d4-5 = -4)

**Parser Bug Fix**:
- Fix modifier chaining: 4d6dl1kh3 now parses as (4d6dl1)kh3
- Change binding power from BP.MODIFIER to BP.DICE_LEFT
- Prevents modifiers in count position while allowing computed counts
- Satisfies PRD requirement for modifier chaining (line 478)

**Tests**:
- 37 evaluator unit tests (using MockRNG for determinism)
- 5 parser tests for modifier chaining
- Total: 186 tests passing (all green)

**Documentation**:
- Document evaluator limitation: sequential vs Roll20 behavior
- Add gitignore entries for package-lock.json and pnpm-lock.yaml
- Created follow-up issue #12 for evaluator refactor (Stage 2/3)

**Validation**: All checks pass (typecheck, lint, format, build, test)

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@edloidas edloidas self-assigned this Jan 5, 2026
@edloidas edloidas linked an issue Jan 5, 2026 that may be closed by this pull request
11 tasks
@edloidas edloidas merged commit c3b14f0 into master Jan 5, 2026
8 checks passed
@edloidas edloidas deleted the claude/review-next-issue-9mnI3 branch January 5, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: implement AST evaluator with modifiers

2 participants