From bed2f3df016ee054d3d24d3c4daad3c14d65970e Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Fri, 19 Aug 2022 12:04:04 +0200 Subject: [PATCH] Moved rng back to main --- Coin/Coin.go | 2 -- Dice/Dice.go | 7 ------- main.go | 3 +++ 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Coin/Coin.go b/Coin/Coin.go index a8e6cfa..4dc7414 100644 --- a/Coin/Coin.go +++ b/Coin/Coin.go @@ -4,13 +4,11 @@ import ( "fmt" "math/rand" "strings" - "time" "gitlab.com/EternalWanderer/dice-roller/Colors" ) func Toss(castAmount int) { - rand.Seed(time.Now().Unix()) var ( coins []string coin string diff --git a/Dice/Dice.go b/Dice/Dice.go index a2d010f..c116ed1 100644 --- a/Dice/Dice.go +++ b/Dice/Dice.go @@ -4,7 +4,6 @@ import ( "fmt" "math/rand" "strings" - "time" "gitlab.com/EternalWanderer/dice-roller/Colors" ) @@ -13,12 +12,7 @@ var ( surfaces, diceThrows, modidier int ) -func genSeed() { - rand.Seed(time.Now().Unix()) -} - func Cast(surfaces, diceThrows, modifier int) { - genSeed() var ( casts []int cast, total int @@ -52,7 +46,6 @@ func Cast(surfaces, diceThrows, modifier int) { } func SimpleCast(modifier int) int { - genSeed() var cast = rand.Intn(20) + 1 diff --git a/main.go b/main.go index 3ddb91f..73f575a 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,9 @@ package main import ( "flag" "fmt" + "math/rand" "os" + "time" "gitlab.com/EternalWanderer/dice-roller/Coin" "gitlab.com/EternalWanderer/dice-roller/Colors" @@ -17,6 +19,7 @@ var ( func main() { ParseFlags() + rand.Seed(time.Now().Unix()) switch {