Documentation ¶
Overview ¶
Package dice provides a library for rolling tabletop role-playing style dice via a text description similar to that used in such games.
Examples
dice.Roll("3d6") // Roll and sum 3 six-sided dice dice.Roll("1d20+2") // Roll a twenty-sided die and add 2
Supported formats ¶
Standard: `xdy[[k|d][h|l]z][+/-c]` - rolls and sums x y-sided dice, keeping or dropping the lowest or highest z dice and optionally adding or subtracting c. Example: 4d6kh3+4
Fudge: `xdf[+/-c]` - rolls and sums x fudge dice (Dice that return numbers between -1 and 1), and optionally adding or subtracting c. Example: 4df+4
Versus: `xdy[e|r]vt` - rolls x y-sided dice, counting the number that roll t or greater.
EotE: `xc [xc ...]` - rolls x dice of color c (b, blk, g, p, r, w, y) and returns the aggregate result.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EoteDie ¶
type EoteResult ¶
func (EoteResult) Description ¶
func (r EoteResult) Description() string
func (EoteResult) Int ¶
func (r EoteResult) Int() int
func (EoteResult) String ¶
func (r EoteResult) String() string
type EoteRoller ¶
type EoteRoller struct{}
func (EoteRoller) Pattern ¶
func (EoteRoller) Pattern() *regexp.Regexp
func (EoteRoller) Roll ¶
func (EoteRoller) Roll(matches []string) (RollResult, error)
type FudgeResult ¶
func (FudgeResult) Description ¶
func (r FudgeResult) Description() string
func (FudgeResult) Int ¶
func (r FudgeResult) Int() int
func (FudgeResult) String ¶
func (r FudgeResult) String() string
type FudgeRoller ¶
type FudgeRoller struct{}
func (FudgeRoller) Pattern ¶
func (FudgeRoller) Pattern() *regexp.Regexp
func (FudgeRoller) Roll ¶
func (FudgeRoller) Roll(matches []string) (RollResult, error)
type RollResult ¶
RollResult is an interface to describe a dice roll and its outcome.
RollResult contains fmt.Stringer, and calling `String()` on a RollResult will get a textual description of the roll outcome.
Description returns a textual description of the roll. This is often the same as the input to dice.Roll.
Int will get the result of the roll as an integer.
type StdResult ¶
type StdResult struct { Rolls []int Dropped []int Total int // contains filtered or unexported fields }
func (StdResult) Description ¶
func (r StdResult) Description() string