From 3f438abb68d3304e73f7497327d926f609f0d622 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Mon, 9 Oct 2017 00:41:51 -0700 Subject: [PATCH] Removed time from battle function;added initGame and ClearScreen_ --- battle.go | 7 +++---- main.go | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/battle.go b/battle.go index d9c34b1..bf67b12 100644 --- a/battle.go +++ b/battle.go @@ -14,12 +14,11 @@ type Character struct { Spell Spell } -func Battle(hero, enemy Character, speed time.Duration) { - speed *= time.Second +func Battle(hero, enemy Character) { + speed := time.Second - rand.Seed(time.Now().Unix()) fmt.Println("Random Int: ", rand.Intn(11)) - //time.Sleep(speed) + time.Sleep(speed) print("Hero: ", hero.Name, "\n") print("Enemy: ", enemy.Name, "\n") diff --git a/main.go b/main.go index af5401b..7c66d91 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,12 @@ package main -import "fmt" +import ( + "fmt" + "math/rand" + "os" + "os/exec" + "time" +) //Characters var ( @@ -28,6 +34,18 @@ var ( ) func main() { - Battle(player, goblin, 1) + initGame() + Battle(player, goblin) fmt.Println(goblin.Weapons[0].Damage) } + +func initGame() { + rand.Seed(time.Now().Unix()) + ClearScreen() +} + +func ClearScreen() { + cmd := exec.Command("clear") + cmd.Stdout = os.Stdout + cmd.Run() +}