diff --git a/golangr/file-reader/main.go b/golangr/file-reader/main.go index 5ea2c8f..2ec690d 100644 --- a/golangr/file-reader/main.go +++ b/golangr/file-reader/main.go @@ -8,9 +8,23 @@ import ( //"strconv" ) +type PlayerStats struct { + name string + lives uint8 +} + +var player PlayerStats var names = []string{} var err error var guess string +var guessLetter rune + +func scanLine() (line string) { + in := bufio.NewReader(os.Stdin) + line, err := in.ReadString('\n') + catchErr(err) + return line +} func main() { if len(os.Args) < 2 || len(os.Args) > 2 { @@ -18,18 +32,28 @@ func main() { os.Exit(1) } + fmt.Printf("Welcome to the hanged man game!\nMay I know your name?\nName: ") + // _, err = fmt.Scanln(&player.name) + // catchErr(err) + player.name = scanLine() + + fmt.Println(player.name) + filePath := os.Args[1] randWord := getWord(filePath) fmt.Printf("The chosen name is %v\n", randWord) - fmt.Scan(&guess) + // fmt.Scan(&guess) + fmt.Scanln(&guessLetter) + // if guess == randWord { + // fmt.Printf("You win!\n") + // } else { + // fmt.Printf("You lose!\n") + // } - if guess == randWord { - fmt.Printf("You win!\n") - } else { - fmt.Printf("You lose!\n") - } +} +func letterCheck(char rune) { } func catchErr(err error) {