Fixed crashing without arguments
This commit is contained in:
parent
92d4ff62f3
commit
ca05ff2eba
Binary file not shown.
|
@ -8,8 +8,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
//"time"
|
|
||||||
//"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PlayerStats struct {
|
type PlayerStats struct {
|
||||||
|
@ -26,8 +24,8 @@ 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 filePath string
|
||||||
var randWord string = getWord(filePath)
|
var randWord string
|
||||||
var hiddenChars []string
|
var hiddenChars []string
|
||||||
|
|
||||||
func scanLine() (line string) {
|
func scanLine() (line string) {
|
||||||
|
@ -43,6 +41,8 @@ func main() {
|
||||||
fmt.Println("Usage: ./file-reader names.txt")
|
fmt.Println("Usage: ./file-reader names.txt")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
filePath = os.Args[1]
|
||||||
|
randWord = getWord(filePath)
|
||||||
|
|
||||||
for range randWord {
|
for range randWord {
|
||||||
hiddenChars = append(hiddenChars, "_")
|
hiddenChars = append(hiddenChars, "_")
|
||||||
|
@ -91,8 +91,6 @@ func gameStatus() {
|
||||||
|
|
||||||
func game() {
|
func game() {
|
||||||
clear()
|
clear()
|
||||||
//filePath := os.Args[1]
|
|
||||||
//randWord := getWord(filePath)
|
|
||||||
for {
|
for {
|
||||||
gameStatus()
|
gameStatus()
|
||||||
if player.lives < 0 {
|
if player.lives < 0 {
|
||||||
|
|
Loading…
Reference in New Issue