This commit is contained in:
raul 2024-02-11 16:30:42 +01:00
parent 01a822c9ab
commit 092619f4bb
1 changed files with 5 additions and 5 deletions

View File

@ -14,7 +14,7 @@ import (
type PlayerStats struct { type PlayerStats struct {
name string name string
lives uint8 lives int8
} }
func clear() { func clear() {
@ -54,7 +54,7 @@ func main() {
//TODO: fix this garbage //TODO: fix this garbage
intLives, err := strconv.Atoi(stringLives) intLives, err := strconv.Atoi(stringLives)
catchErr(err) catchErr(err)
player.lives = uint8(intLives) player.lives = int8(intLives)
clear() clear()
fmt.Printf("Name: %v\n", player.name) fmt.Printf("Name: %v\n", player.name)
@ -87,7 +87,7 @@ func game() {
randWord := getWord(filePath) randWord := getWord(filePath)
for { for {
gameStatus() gameStatus()
if player.lives == 0 { if player.lives < 0 {
fmt.Println("You lose!") fmt.Println("You lose!")
os.Exit(0) os.Exit(0)
} }
@ -97,9 +97,9 @@ func game() {
fmt.Println("You win!") fmt.Println("You win!")
os.Exit(0) os.Exit(0)
} else { } else {
fmt.Println("Wrong!") fmt.Printf("Wrong!")
player.lives-- player.lives--
time.Sleep(2 * time.Second) time.Sleep(1 * time.Second)
clear() clear()
} }
} }