mirror of
https://gitlab.com/EternalWanderer/dice-roller.git
synced 2024-11-29 05:13:50 +01:00
Initial commit
This commit is contained in:
commit
943b758c5c
BIN
dice-roller
Executable file
BIN
dice-roller
Executable file
Binary file not shown.
3
go.mod
Normal file
3
go.mod
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module git.voidcruiser.nl/Azathoth/dice-roller
|
||||||
|
|
||||||
|
go 1.17
|
40
main.go
Normal file
40
main.go
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var surfaces, throws int
|
||||||
|
rand.Seed(time.Now().Unix())
|
||||||
|
// fmt.Println("Half arsed version without error checking.")
|
||||||
|
// fmt.Println("Please insert number of die surfaces followed by amount of dice thrown.")
|
||||||
|
// fmt.Scanf("%d %d", &surfaces, &throws)
|
||||||
|
flag.IntVar(&surfaces, "s", 20, "Specify die type")
|
||||||
|
flag.IntVar(&throws, "t", 1, "Specify dice throws")
|
||||||
|
flag.Parse()
|
||||||
|
fmt.Println(surfaces)
|
||||||
|
fmt.Println(throws)
|
||||||
|
fmt.Println(Cast(surfaces, throws))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Cast(dieSurfaces, castAmount int) int {
|
||||||
|
fmt.Println(dieSurfaces)
|
||||||
|
fmt.Println(castAmount)
|
||||||
|
var (
|
||||||
|
casts []int
|
||||||
|
cast, total int
|
||||||
|
)
|
||||||
|
|
||||||
|
for i := 0; i < castAmount; i++ {
|
||||||
|
cast = rand.Intn(dieSurfaces) + 1
|
||||||
|
casts = append(casts, cast)
|
||||||
|
total += cast
|
||||||
|
}
|
||||||
|
fmt.Println(casts)
|
||||||
|
return total
|
||||||
|
}
|
Loading…
Reference in a new issue