Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Die ¶
type Die struct {
Value int // The rolled value
Sides int // Number of sides on this die
Kept bool // Whether this die counts toward the total
}
Die represents a single rolled die
type Expression ¶
type Expression struct {
Count int // Number of dice to roll
Sides int // Sides per die
Modifier int // +/- modifier to add to total
Operation *Operation // Optional keep/drop operation
Advantage bool // Per-die advantage (roll each die twice, keep highest)
}
Expression represents a dice notation to be rolled (input)
func Parse ¶
func Parse(notation string) (*Expression, error)
Parse parses a dice notation string into an Expression Supports: XdY, XdY+Z, XdY!, XdYkhN, XdYdlN, etc.
type Result ¶
type Result struct {
Expression *Expression // Original expression that created this result
Rolls []Die // All dice rolled (including dropped)
KeptTotal int // Sum of kept dice only
Total int // Final result (kept + modifier)
}
Result represents the outcome of rolling dice (output)
func RollExpression ¶
func RollExpression(expr *Expression) (*Result, error)
RollExpression rolls dice according to an Expression and returns a Result
type Roll ¶
type Roll struct {
Notation string // e.g., "2d6"
Count int // number of dice
Sides int // sides per die
Results []int // individual die results
Total int // sum of all results
}
Roll represents the result of a dice roll (legacy/backward compatibility)
Click to show internal directories.
Click to hide internal directories.