Cleaning up code and adding hiddenChar viewer
This commit is contained in:
parent
092619f4bb
commit
8ab370f705
|
@ -1,3 +1,3 @@
|
|||
module file-reader
|
||||
|
||||
go 1.21.6
|
||||
go 1.22
|
||||
|
|
|
@ -26,6 +26,9 @@ var names = []string{}
|
|||
var err error
|
||||
var guess string
|
||||
var guessLetter rune
|
||||
var filePath string = os.Args[1]
|
||||
var randWord string = getWord(filePath)
|
||||
var hiddenChars []string
|
||||
|
||||
func scanLine() (line string) {
|
||||
in := bufio.NewReader(os.Stdin)
|
||||
|
@ -41,6 +44,10 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
for range randWord {
|
||||
hiddenChars = append(hiddenChars, "_")
|
||||
}
|
||||
|
||||
for {
|
||||
clear()
|
||||
|
||||
|
@ -79,12 +86,13 @@ func gameStatus() {
|
|||
clear()
|
||||
fmt.Println("Player:", player.name)
|
||||
fmt.Println("Lives:", player.lives)
|
||||
fmt.Println("Word:", hiddenChars)
|
||||
}
|
||||
|
||||
func game() {
|
||||
clear()
|
||||
filePath := os.Args[1]
|
||||
randWord := getWord(filePath)
|
||||
//filePath := os.Args[1]
|
||||
//randWord := getWord(filePath)
|
||||
for {
|
||||
gameStatus()
|
||||
if player.lives < 0 {
|
||||
|
|
Loading…
Reference in New Issue