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
|
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
22
main.go
@ -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()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user