Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

2 changed files with 5 additions and 16 deletions

View File

@ -15,10 +15,7 @@ go build .
```bash ```bash
% ./gordle --help % ./gordle --help
Usage of ./gordle: Usage of ./gordle:
-f string
Path to dictionary file with words of length -n. If specified, -n must be specified too (if the latter must not be equal to default value (default "./dictionary/5.txt")
-n int -n int
Word size (default 5) Word size (default 5)
``` ```
@ -31,4 +28,4 @@ go test # [-cover]
## Dictionaries ## Dictionaries
To run game you also need dictionary files. By default gordle searches for them in `./dictionary/<n>.txt` file, where `<n>` - number of characters, specified by `-n` flag. If want to use custom one, provide in `-f` flag path to txt file with strings separated by new line characters To run game you also need dictionary files. By default gordle searches for them in `./dictionary/<n>.txt` file, where `<n>` - number of characters, specified by `-n` flag

View File

@ -26,17 +26,13 @@ func main() {
containsOutput := color.New(color.BgYellow, color.FgBlack) containsOutput := color.New(color.BgYellow, color.FgBlack)
wrongOutput := color.New(color.BgWhite, color.FgBlack) wrongOutput := color.New(color.BgWhite, color.FgBlack)
nFlag := flag.Int("n", 5, "Word size") var nFlag = flag.Int("n", 5, "Word size")
fFlag := flag.String("f", "./dictionary/5.txt", "Path to dictionary file with words of length -n. If specified, -n must be specified too (if the latter must not be equal to default value")
flag.Parse() flag.Parse()
nChar := *nFlag
fmt.Println("Welcome to Gordle - go implementation of Wordle game") fmt.Println("Welcome to Gordle - go implementation of Wordle game")
nChar := *nFlag file, err := os.Open(fmt.Sprintf("./dictionary/%d.txt", nChar))
filePath := *fFlag
file, err := os.Open(filePath)
if err != nil { if err != nil {
log.Fatal("There is no dictionary with such amount of letters") log.Fatal("There is no dictionary with such amount of letters")
@ -52,10 +48,6 @@ func main() {
words = append(words, scanner.Text()) words = append(words, scanner.Text())
} }
if len(words[0]) != nChar {
log.Fatal("Words in dictionary must be of size", nChar)
}
fmt.Printf("You are going to guess a %d letter word in %d tries from %d dictionary\n", nChar, nChar+1, len(words)) fmt.Printf("You are going to guess a %d letter word in %d tries from %d dictionary\n", nChar, nChar+1, len(words))
rand.Seed(time.Now().Unix()) rand.Seed(time.Now().Unix())