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