Added way to roll multiple attacks

This commit is contained in:
Azathoth 2021-09-16 11:59:45 +02:00
parent 322f706e4d
commit b45c2ab92b
2 changed files with 18 additions and 9 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
dice-roller
.idea

26
main.go
View file

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