Removed time from battle function;added initGame and ClearScreen_
This commit is contained in:
parent
d623b8ba2a
commit
3f438abb68
@ -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
22
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()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user