From 1aaeede1779b067a5a372df087e67eed7ed9590f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstancja=20=C5=81ukawska?= Date: Fri, 12 Apr 2024 00:22:43 -0400 Subject: [PATCH] Fix docs --- wordle_attempt.go | 3 +++ wordle_engine.go | 14 ++++++++------ wordle_game.go | 6 +++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/wordle_attempt.go b/wordle_attempt.go index cd96670..034e450 100644 --- a/wordle_attempt.go +++ b/wordle_attempt.go @@ -1,5 +1,8 @@ package wordle +// WordleAttempt represents an attempt to guess the +// current game answer, and the status of each character +// as represented by the [wordle.CharacterStatus] enum. type WordleAttempt struct { Guess []rune Result []CharacterStatus diff --git a/wordle_engine.go b/wordle_engine.go index 85ebafd..3766f40 100644 --- a/wordle_engine.go +++ b/wordle_engine.go @@ -16,11 +16,12 @@ type WordleEngine struct { CurrentGame *WordleGame } -// NewWordleEngine constructs a *WordleEngine using the -// dictionary at the path provided, and a mx number of attempts. +// NewWordleEngine returns a pointer to a [wordle.WordleEngine], +// using the dictionary at the path provided, and a maximum +// number of attempts. // -// The `dictionaryPath` parameter should point to a newline -// terminated list of equal-`rune`-length word strings. +// The dictionaryPath parameter should point to a newline +// terminated list of equal-[rune]-length word strings. func NewWordleEngine(dictionaryPath string, maxAttempts int) (*WordleEngine, error) { dictionary, err := openDictionary(dictionaryPath) if err != nil { @@ -40,7 +41,8 @@ func NewWordleEngine(dictionaryPath string, maxAttempts int) (*WordleEngine, err } // NewGame starts instantiates a new *WordleGame when there is no -// previous game in `we.CurrentGame`, or the previous game is over. +// previous game in [wordle.WordleEngine.CurrentGame], or the +// previous game is over. func (we *WordleEngine) NewGame() error { if we.CurrentGame == nil || we.CurrentGame.Status == WordleGameStatusGameOver { word, err := we.RandomDictionaryWord() @@ -73,7 +75,7 @@ func (we *WordleEngine) RandomDictionaryWord() (string, error) { // openDictionary reads a newline terminated dictionary file // containing equal-length words, and returns the words as a -// slice of `string` values. +// slice of [string] values. func openDictionary(path string) ([]string, error) { file, err := os.ReadFile(path) if err != nil { diff --git a/wordle_game.go b/wordle_game.go index 8cfc253..5334811 100644 --- a/wordle_game.go +++ b/wordle_game.go @@ -25,8 +25,8 @@ const ( WordleGameStatusWon ) -// WordleError represents an WordleGame error response, containing -// the current game status. +// WordleError represents an error response used by +// [wordle.WordleGame], containing the current game status. type WordleError struct { Status WordleGameStatus } @@ -48,7 +48,7 @@ func (wg *WordleGame) GetAnswer() string { // The game status is updated when a win (correct guess) or game over // condition (last remaining guess is incorrect) is met. // -// An error is returned if the game state is `WordleStateGameOver`, or +// An error is returned if the game state is [wordle.WordleStateGameOver], or // the last remaining guess was incorrect. func (wg *WordleGame) Attempt(word string) (bool, error) { if wg.Status == WordleGameStatusGameOver {