wordle

package
v0.0.0-...-e5f450f Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Green = "green" // "\033[32m"

var Reset = "\033[0m" var Red = "\033[31m"

View Source
var MaxApptemps int = 5
View Source
var MaxWordLen int = 25
View Source
var MinWordLen int = 3
View Source
var Yellow = "yellow" // "\033[33m"

Functions

func ClearTerminal

func ClearTerminal()

func ComposeWordleVisualWord

func ComposeWordleVisualWord(word string, target *model.Word) string

func GetSaltsFromWord

func GetSaltsFromWord(word *model.Word) []string

func IsGuessSuccess

func IsGuessSuccess(result []bool) bool

func IsLetter

func IsLetter(s string) bool

Types

type HeaderRequest

type HeaderRequest struct {
	Height int // 0 means give me the latest
}

func (*HeaderRequest) MarshalTo

func (h *HeaderRequest) MarshalTo(bytes []byte) (int, error)

func (*HeaderRequest) Size

func (h *HeaderRequest) Size() int

func (*HeaderRequest) Unmarshal

func (h *HeaderRequest) Unmarshal(bytes []byte) error

type HeaderResponse

type HeaderResponse struct {
	Header *model.Header
}

func (*HeaderResponse) MarshalTo

func (h *HeaderResponse) MarshalTo(bytes []byte) (int, error)

func (*HeaderResponse) Size

func (h *HeaderResponse) Size() int

func (*HeaderResponse) Unmarshal

func (h *HeaderResponse) Unmarshal(bytes []byte) error

type Service

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

func NewService

func NewService(host core.Host, ds datastore.Batching, pubsub *pubsub.PubSub) *Service

func (*Service) Guess

func (s *Service) Guess(ctx context.Context, guess, proposal string) error

func (*Service) Guesses

func (s *Service) Guesses(ctx context.Context) (<-chan *model.Header, error)

func (*Service) Head

func (s *Service) Head(ctx context.Context) (*model.Header, error)

func (*Service) SetLog

func (s *Service) SetLog(log func(string))

func (*Service) Start

func (s *Service) Start(ctx context.Context) (err error)

func (*Service) Stop

func (s *Service) Stop(context.Context) error

type Store

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

func NewStore

func NewStore(ds datastore.Batching) *Store

func (*Store) Append

func (s *Store) Append(ctx context.Context, h *model.Header) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, height int) (*model.Header, error)

func (*Store) Head

func (s *Store) Head(ctx context.Context) (*model.Header, error)

func (*Store) Init

func (s *Store) Init(ctx context.Context) error

type TerminalManager

type TerminalManager struct {
	Game *WordGame

	OthersGuessC chan struct{}
	// contains filtered or unexported fields
}

TerminalManager is a Text User Interface (TUI) for a ChatRoom. The Run method will draw the UI to the terminal in "fullscreen" mode. You can quit with Ctrl-C, or by typing "/quit" into the chat prompt.

func NewTerminalManager

func NewTerminalManager(ctx context.Context, game *WordGame) *TerminalManager

NewTerminalManager returns a new TerminalManager struct that controls the text UI. It won't actually do anything until you call Run().

func (*TerminalManager) AddDebugItem

func (ui *TerminalManager) AddDebugItem(s string)

func (*TerminalManager) Run

func (ui *TerminalManager) Run() error

type WordGame

type WordGame struct {
	PeerId string

	// to verify if the guess is correct
	Target *model.Word
	Salts  []string

	StateIdx int32
	NextWord string

	AttemptedWords []string
	// contains filtered or unexported fields
}

func NewWordGame

func NewWordGame(ctx context.Context, peerId string, proposerId string, target *model.Word, serv *Service) *WordGame

generate new game session

func (*WordGame) ComposeStateUI

func (w *WordGame) ComposeStateUI() string

func (*WordGame) NewStdinInput

func (w *WordGame) NewStdinInput(input string) error

func (*WordGame) WasGuessed

func (w *WordGame) WasGuessed() bool

type WordleUI

type WordleUI struct {
	PeerId string

	WordleServ  *Service
	CurrentGame *WordGame

	CannonicalHeader *model.Header
	// contains filtered or unexported fields
}

func NewWordleUI

func NewWordleUI(ctx context.Context, wordleServ *Service, peerId string) *WordleUI

func (*WordleUI) AddDebugItem

func (w *WordleUI) AddDebugItem(s string)

func (*WordleUI) Run

func (w *WordleUI) Run()

Jump to

Keyboard shortcuts

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