-
Notifications
You must be signed in to change notification settings - Fork 0
/
dice.go
54 lines (44 loc) · 1.02 KB
/
dice.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package dice
import (
"github.com/jfmario/dice/internal/compute"
"github.com/jfmario/dice/pkg/dice_group"
"github.com/jfmario/dice/pkg/die"
)
6
// NewDie creates a die with the given number of sides.
func NewDie(sides int) *die.Die {
return die.New(sides)
}
// D4 returns a new die with four sides.
func D4() *die.Die {
return die.D4()
}
// D6 returns a new die with six sides.
func D6() *die.Die {
return die.D6()
}
// D8 returns a new die with eight sides.
func D8() *die.Die {
return die.D8()
}
// D10 returns a new die with ten sides.
func D10() *die.Die {
return die.D10()
}
// D12 returns a new die with twelve sides.
func D12() *die.Die {
return die.D12()
}
// D20 returns a new die with twenty sides.
func D20() *die.Die {
return die.D20()
}
// New creates a new, empty dice group
func NewDiceGroup() *dice_group.DiceGroup {
return dice_group.New()
}
// Compute is a function that parses a string like "2d6 + 1".
func Compute(diceString string) (int, error) {
val, err := compute.Compute(diceString)
return val, err
}