Compare commits

..

8 Commits
v1 ... master

2 changed files with 15 additions and 2 deletions

View File

@ -1,3 +1,13 @@
# roll
A simple die roller
A simple die roller
Example Usage:
Just roll a single d20
`roll`
Roll 5 d20 7 times
`roll 5d20x7`

View File

@ -20,6 +20,9 @@ func main() {
parm = os.Args[1] + "d" + os.Args[2]
}
}
if strings.HasPrefix(parm, "d") {
parm = "1" + parm
}
r = rand.New(rand.NewSource(time.Now().UnixNano()))
num, sides, times := parseParm(parm)
@ -58,7 +61,7 @@ func parseParm(p string) (int, int, int) {
func roll(num, sides int) int {
ret := 0
for ; num > 0; num-- {
ret += r.Intn(sides)
ret += r.Intn(sides) + 1
}
return ret
}