Added modifier flag

This commit is contained in:
Nox Sluijtman 2021-08-28 12:36:16 +02:00
parent 2864a3298a
commit 322f706e4d

19
main.go
View file

@ -8,16 +8,22 @@ import (
) )
func main() { func main() {
var surfaces, throws int var surfaces, modifier, diceThrows int
rand.Seed(time.Now().Unix()) rand.Seed(time.Now().Unix())
flag.IntVar(&surfaces, "s", 20, "Specify amount of die surfaces") flag.IntVar(&surfaces, "s", 20, "Specify amount of die surfaces")
flag.IntVar(&throws, "t", 1, "Specify dice throws") flag.IntVar(&diceThrows, "t", 1, "Specify dice diceThrows")
flag.IntVar(&modifier, "m", 0, "Stat modifier")
flag.Parse() flag.Parse()
Cast(surfaces, throws) total := Cast(surfaces, diceThrows)
if modifier != 0 {
fmt.Println("Without modifier:", total)
fmt.Println("With modifier:", total+modifier)
} else {
fmt.Println(total)
}
} }
func Cast(dieSurfaces, castAmount int) { func Cast(dieSurfaces, castAmount int) int {
var ( var (
casts []int casts []int
cast, total int cast, total int
@ -32,6 +38,5 @@ func Cast(dieSurfaces, castAmount int) {
if castAmount > 1 { if castAmount > 1 {
fmt.Println(casts) fmt.Println(casts)
} }
return total
fmt.Println(total)
} }