Removed time from battle function;added initGame and ClearScreen_

This commit is contained in:
Logen Kain 2017-10-09 00:41:51 -07:00
parent d623b8ba2a
commit 3f438abb68
2 changed files with 23 additions and 6 deletions

View File

@ -14,12 +14,11 @@ type Character struct {
Spell Spell Spell Spell
} }
func Battle(hero, enemy Character, speed time.Duration) { func Battle(hero, enemy Character) {
speed *= time.Second speed := time.Second
rand.Seed(time.Now().Unix())
fmt.Println("Random Int: ", rand.Intn(11)) fmt.Println("Random Int: ", rand.Intn(11))
//time.Sleep(speed) time.Sleep(speed)
print("Hero: ", hero.Name, "\n") print("Hero: ", hero.Name, "\n")
print("Enemy: ", enemy.Name, "\n") print("Enemy: ", enemy.Name, "\n")

22
main.go
View File

@ -1,6 +1,12 @@
package main package main
import "fmt" import (
"fmt"
"math/rand"
"os"
"os/exec"
"time"
)
//Characters //Characters
var ( var (
@ -28,6 +34,18 @@ var (
) )
func main() { func main() {
Battle(player, goblin, 1) initGame()
Battle(player, goblin)
fmt.Println(goblin.Weapons[0].Damage) 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()
}