mirror of
https://gitlab.com/EternalWanderer/dice-roller.git
synced 2024-11-28 21:03:51 +01:00
Added modifier flag
This commit is contained in:
parent
2864a3298a
commit
322f706e4d
19
main.go
19
main.go
|
@ -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)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue