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
|
||||
.idea
|
||||
|
|
26
main.go
26
main.go
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue