How randsum/randsum-ts works
Main Components
a. Core Components:
• Dice Engine (src/dice)
• Custom Faces Handler (src/faces)
• Notation Parser (src/notation)
• Roll Tower (src/tower)
• Utilities (src/utils)
Top Layer: Public API
Middle Layer: Core Processing
Bottom Layer: Utility Services
Component Relationships
a. Public API Layer:
• Main entry points: roll() function and D class
• To the notation parser for string inputs
• To the dice engine for direct numeric/configuration inputs
b. Core Processing Layer:
• Notation Parser: Show how it processes dice notation strings
• Dice Engine: Illustrate dice creation and basic rolling
• Custom Faces Handler: Show custom dice face processing
• Roll Tower: Demonstrate roll execution and modifier application
c. Utility Layer:
• Configuration Processors
• Random Number Generation
• Result Formatters
• Type Guards and Validators
Specific Implementation Details
Key features:
• How the dice notation parser ('4d6L') flows through the system
• Custom faces feature (['heads', 'tails'])
• Demonstrate modifier application flow (drop lowest, etc.)
• Validation pathways
Flow Directions
• Input flow from API to core components
• Data transformation between components
• Result aggregation and return paths
Type safety and validation paths
• All component types
• Special symbols used
This system design should help developers understand how randsum processes both simple rolls like roll(20) and complex operations like roll('4d6L') through its various components while maintaining type safety and flexibility.