mirror of
https://gitlab.com/EternalWanderer/dice-roller.git
synced 2024-11-28 21:03:51 +01:00
Added way to roll multiple attacks
This commit is contained in:
parent
322f706e4d
commit
b45c2ab92b
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
dice-roller
|
dice-roller
|
||||||
|
.idea
|
||||||
|
|
26
main.go
26
main.go
|
@ -8,22 +8,24 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var surfaces, modifier, diceThrows int
|
var surfaces, modifier, diceThrows, attacks 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(&diceThrows, "t", 1, "Specify dice diceThrows")
|
flag.IntVar(&diceThrows, "t", 1, "Specify dice diceThrows")
|
||||||
flag.IntVar(&modifier, "m", 0, "Stat modifier")
|
flag.IntVar(&modifier, "m", 0, "Stat modifier")
|
||||||
|
flag.IntVar(&attacks, "a", 1, "Attacks")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
total := Cast(surfaces, diceThrows)
|
|
||||||
if modifier != 0 {
|
for i := 0; i < attacks; i++ {
|
||||||
fmt.Println("Without modifier:", total)
|
if attacks > 1 {
|
||||||
fmt.Println("With modifier:", total+modifier)
|
fmt.Println()
|
||||||
} else {
|
}
|
||||||
fmt.Println(total)
|
Cast(surfaces, diceThrows, modifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Cast(dieSurfaces, castAmount int) int {
|
func Cast(dieSurfaces, castAmount, modifier int) {
|
||||||
var (
|
var (
|
||||||
casts []int
|
casts []int
|
||||||
cast, total int
|
cast, total int
|
||||||
|
@ -38,5 +40,11 @@ func Cast(dieSurfaces, castAmount int) int {
|
||||||
if castAmount > 1 {
|
if castAmount > 1 {
|
||||||
fmt.Println(casts)
|
fmt.Println(casts)
|
||||||
}
|
}
|
||||||
return total
|
|
||||||
|
if modifier != 0 {
|
||||||
|
fmt.Println("Without modifier:", total)
|
||||||
|
fmt.Println("With modifier:", total+modifier)
|
||||||
|
} else {
|
||||||
|
fmt.Println(total)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue