Spaced guesses no longer pass sanity checks
Players could input guesses such as "b FOOBAR" with the program still picking up the "b" character, any input with spaces in it will now be ignored.
This commit is contained in:
parent
f93efc0986
commit
6656971e10
25
main.go
25
main.go
|
@ -185,9 +185,10 @@ func game() {
|
||||||
checkEmpty:
|
checkEmpty:
|
||||||
for {
|
for {
|
||||||
fmt.Printf("Guess: ")
|
fmt.Printf("Guess: ")
|
||||||
fmt.Scanln(&guess)
|
//fmt.Scanln(&guess)
|
||||||
|
guess = scanLine()
|
||||||
|
|
||||||
if isEmpty(guess) == false {
|
if isEmpty(guess) == false && len([]rune(guess)) == 1 {
|
||||||
break checkEmpty
|
break checkEmpty
|
||||||
} else {
|
} else {
|
||||||
gameStatus()
|
gameStatus()
|
||||||
|
@ -195,8 +196,6 @@ func game() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: prevent players from inputting multiple characters, UTF-8 is gonna be a pain
|
|
||||||
|
|
||||||
if getLetter(guess) == true {
|
if getLetter(guess) == true {
|
||||||
if alreadyCorrect(guess) == true {
|
if alreadyCorrect(guess) == true {
|
||||||
fmt.Printf("[-] You've already guessed this correct letter")
|
fmt.Printf("[-] You've already guessed this correct letter")
|
||||||
|
@ -250,24 +249,6 @@ func getWord(path string) (word string) {
|
||||||
return randName
|
return randName
|
||||||
}
|
}
|
||||||
|
|
||||||
// func setClear() {
|
|
||||||
// switch runtime.GOOS {
|
|
||||||
// case "linux":
|
|
||||||
// fmt.Println("You're using linux")
|
|
||||||
// time.Sleep(1 * time.Second)
|
|
||||||
// clearCommand = exec.Command("clear")
|
|
||||||
// clearCommand.Stdout = os.Stdout
|
|
||||||
// case "windows":
|
|
||||||
// fmt.Println("You're using windows")
|
|
||||||
// time.Sleep(1 * time.Second)
|
|
||||||
// clearCommand = exec.Command("cmd", "/c", "cls")
|
|
||||||
// clearCommand.Stdout = os.Stdout
|
|
||||||
// default:
|
|
||||||
// fmt.Println("Huh?")
|
|
||||||
// os.Exit(1)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
func clear() {
|
func clear() {
|
||||||
screen.Clear()
|
screen.Clear()
|
||||||
screen.MoveTopLeft()
|
screen.MoveTopLeft()
|
||||||
|
|
Loading…
Reference in New Issue