Added the actual game
This commit is contained in:
parent
d1fddbe7ee
commit
01a822c9ab
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue