Initial commit

This commit is contained in:
Nox Sluijtman 2021-08-23 18:53:20 +02:00
commit 943b758c5c
3 changed files with 43 additions and 0 deletions

BIN
dice-roller Executable file

Binary file not shown.

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module git.voidcruiser.nl/Azathoth/dice-roller
go 1.17

40
main.go Normal file
View 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
}