birdle

package
v0.0.0-...-27647ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

TODO:

  • !! free chars - special chars are pre-filled
  • bitmask chars

https://en.wikipedia.org/wiki/List_of_birds_by_common_name https://en.wikipedia.org/w/api.php?action=parse&page=List_of_birds_by_common_name&format=json&prop=links

Index

Constants

View Source
const DefaultWikiBirdsPage = "List_of_birds_by_common_name"
View Source
const DefaultWordsFilePath = "/usr/share/dict/words"

Variables

This section is empty.

Functions

func CheckWord

func CheckWord(s string) error
func FetchWikiLinks(ctx context.Context, page string) ([]string, error)

func NormalizeWord

func NormalizeWord(s string) string

func PrepareWord

func PrepareWord(word string, filter WordFilter) string

func PrepareWords

func PrepareWords(s []string, filter WordFilter) []string

func ReadWordsFile

func ReadWordsFile(path string, filter WordFilter) (s []string, err error)

Types

type Dictionary

type Dictionary struct {
	// contains filtered or unexported fields
}

func NewDictionary

func NewDictionary(s []string) *Dictionary

func (*Dictionary) Contains

func (d *Dictionary) Contains(w string) bool

func (*Dictionary) Get

func (d *Dictionary) Get(i int) string

func (*Dictionary) Len

func (d *Dictionary) Len() int

func (*Dictionary) Random

func (d *Dictionary) Random() string

type Game

type Game struct {
	// contains filtered or unexported fields
}

func NewGame

func NewGame(word string, guessesAllowed int, dict *Dictionary) (*Game, error)

func (*Game) CheckGuess

func (g *Game) CheckGuess(word string) error

func (*Game) GetGuess

func (g *Game) GetGuess(i int) MarkedWord

func (*Game) Guess

func (g *Game) Guess(word string) error

func (*Game) GuessesAllowed

func (g *Game) GuessesAllowed() int

func (*Game) GuessesLeft

func (g *Game) GuessesLeft() int

func (*Game) GuessesMade

func (g *Game) GuessesMade() int

func (*Game) HasGuessedChar

func (g *Game) HasGuessedChar(c rune) bool

func (*Game) State

func (g *Game) State() State

func (*Game) Word

func (g *Game) Word() string

type Mark

type Mark int8
const (
	Normal Mark = iota
	Correct
	Misplaced
)

type MarkedWord

type MarkedWord interface {
	Word() string
	Mark(int) Mark
}

type Renderer

type Renderer interface {
	RenderWord(MarkedWord) string
	RenderGame(*Game) string
}

type State

type State int8
const (
	Running State = iota
	Lost
	Won
)

func (State) String

func (s State) String() string

type TermRenderer

type TermRenderer struct{}

func (TermRenderer) RenderGame

func (r TermRenderer) RenderGame(g *Game) string

func (TermRenderer) RenderWord

func (r TermRenderer) RenderWord(mw MarkedWord) string

type WordFilter

type WordFilter func(string) bool

func WordLenFilter

func WordLenFilter(i int) WordFilter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL