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
}
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")

22
main.go
View File

@ -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()
}