Cleaned up clode and removed binary

This commit is contained in:
Nox Sluijtman 2021-08-23 23:19:01 +02:00
parent 943b758c5c
commit 3803b90fc0
3 changed files with 11 additions and 13 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
dice-roller

Binary file not shown.

21
main.go
View file

@ -10,21 +10,14 @@ import (
func main() { func main() {
var surfaces, throws int var surfaces, throws int
rand.Seed(time.Now().Unix()) 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.") flag.IntVar(&surfaces, "s", 20, "Specify amount of die surfaces")
// fmt.Scanf("%d %d", &surfaces, &throws)
flag.IntVar(&surfaces, "s", 20, "Specify die type")
flag.IntVar(&throws, "t", 1, "Specify dice throws") flag.IntVar(&throws, "t", 1, "Specify dice throws")
flag.Parse() flag.Parse()
fmt.Println(surfaces) Cast(surfaces, throws)
fmt.Println(throws)
fmt.Println(Cast(surfaces, throws))
} }
func Cast(dieSurfaces, castAmount int) int { func Cast(dieSurfaces, castAmount int) {
fmt.Println(dieSurfaces)
fmt.Println(castAmount)
var ( var (
casts []int casts []int
cast, total int cast, total int
@ -35,6 +28,10 @@ func Cast(dieSurfaces, castAmount int) int {
casts = append(casts, cast) casts = append(casts, cast)
total += cast total += cast
} }
if castAmount > 1 {
fmt.Println(casts) fmt.Println(casts)
return total }
fmt.Println(total)
} }