Added the actual game

This commit is contained in:
raul 2024-02-10 22:20:19 +01:00
parent d1fddbe7ee
commit 01a822c9ab
1 changed files with 15 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import (
"strconv"
"strings"
"time"
//"time"
//"strconv"
)
@ -68,8 +69,6 @@ func main() {
}
}
// filePath := os.Args[1]
// randWord := getWord(filePath)
//
// fmt.Printf("The chosen name is %v\n", randWord)
// fmt.Scanln(&guessLetter)
@ -84,14 +83,25 @@ func gameStatus() {
func game() {
clear()
filePath := os.Args[1]
randWord := getWord(filePath)
for {
gameStatus()
if player.lives == 0 {
fmt.Println("You lose!")
os.Exit(1)
os.Exit(0)
}
time.Sleep(2 * time.Second)
fmt.Printf("Guess: ")
fmt.Scanln(&guess)
if guess == randWord {
fmt.Println("You win!")
os.Exit(0)
} else {
fmt.Println("Wrong!")
player.lives--
time.Sleep(2 * time.Second)
clear()
}
}
}