From 322f706e4d31646b650d0f14746079d4dc278382 Mon Sep 17 00:00:00 2001 From: Azathoth Date: Sat, 28 Aug 2021 12:36:16 +0200 Subject: [PATCH] Added modifier flag --- main.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index f18e024..6a44894 100644 --- a/main.go +++ b/main.go @@ -8,16 +8,22 @@ import ( ) func main() { - var surfaces, throws int + var surfaces, modifier, diceThrows int rand.Seed(time.Now().Unix()) - flag.IntVar(&surfaces, "s", 20, "Specify amount of die surfaces") - flag.IntVar(&throws, "t", 1, "Specify dice throws") + flag.IntVar(&diceThrows, "t", 1, "Specify dice diceThrows") + flag.IntVar(&modifier, "m", 0, "Stat modifier") flag.Parse() - Cast(surfaces, throws) + total := Cast(surfaces, diceThrows) + if modifier != 0 { + fmt.Println("Without modifier:", total) + fmt.Println("With modifier:", total+modifier) + } else { + fmt.Println(total) + } } -func Cast(dieSurfaces, castAmount int) { +func Cast(dieSurfaces, castAmount int) int { var ( casts []int cast, total int @@ -32,6 +38,5 @@ func Cast(dieSurfaces, castAmount int) { if castAmount > 1 { fmt.Println(casts) } - - fmt.Println(total) + return total }