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