Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
clukawski committed Apr 12, 2024
1 parent 53f863c commit 1aaeede
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions wordle_attempt.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 8 additions & 6 deletions wordle_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions wordle_game.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down

0 comments on commit 1aaeede

Please sign in to comment.