turnplayer

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: GPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureKWG added in v0.13.0

func EnsureKWG(lexname string, cfg *wglconfig.Config) error

EnsureKWG checks whether the KWG file for lexname is present and, if not, downloads it from the woogles-io/liwords repository. It is safe to call before any code that calls kwg.GetKWG so that load paths other than "set lexicon" also get the file-not-found download behaviour.

func ParseChallengeRule

func ParseChallengeRule(rule string) (pb.ChallengeRule, error)

func ShowChallengeRule

func ShowChallengeRule(rule pb.ChallengeRule) string

Types

type BaseTurnPlayer

type BaseTurnPlayer struct {
	*game.Game
}

func BaseTurnPlayerFromRules

func BaseTurnPlayerFromRules(opts *GameOptions, players []*pb.PlayerInfo, rules *game.GameRules) (*BaseTurnPlayer, error)

BaseTurnPlayerFromRules is a good entry point

func (*BaseTurnPlayer) IsPlaying

func (p *BaseTurnPlayer) IsPlaying() bool

func (*BaseTurnPlayer) MoveFromEvent

func (p *BaseTurnPlayer) MoveFromEvent(evt *pb.GameEvent) (*move.Move, error)

func (*BaseTurnPlayer) NewChallengeMove

func (p *BaseTurnPlayer) NewChallengeMove(playerid int) (*move.Move, error)

func (*BaseTurnPlayer) NewExchangeMove

func (p *BaseTurnPlayer) NewExchangeMove(playerid int, letters string) (*move.Move, error)

func (*BaseTurnPlayer) NewPassMove

func (p *BaseTurnPlayer) NewPassMove(playerid int) (*move.Move, error)

func (*BaseTurnPlayer) NewPlacementMove

func (p *BaseTurnPlayer) NewPlacementMove(playerid int, coords string, word string, transpose bool) (*move.Move, error)

func (*BaseTurnPlayer) ParseMove

func (p *BaseTurnPlayer) ParseMove(playerid int, lowercase bool, fields []string, transpose bool) (*move.Move, error)

func (*BaseTurnPlayer) SetCurrentRack

func (p *BaseTurnPlayer) SetCurrentRack(letters string) error

func (*BaseTurnPlayer) SetGame

func (p *BaseTurnPlayer) SetGame(g *game.Game)

func (*BaseTurnPlayer) SetPlayerRack

func (p *BaseTurnPlayer) SetPlayerRack(playerid int, letters string) error

type GameOptions

type GameOptions struct {
	Lexicon         *Lexicon
	ChallengeRule   pb.ChallengeRule
	BoardLayoutName string
	Variant         game.Variant
}

func (*GameOptions) SetBoardLayoutName

func (opts *GameOptions) SetBoardLayoutName(name string) error

func (*GameOptions) SetChallenge

func (opts *GameOptions) SetChallenge(rule string) error

func (*GameOptions) SetDefaults

func (opts *GameOptions) SetDefaults(cfg *config.Config)

func (*GameOptions) SetLexicon

func (opts *GameOptions) SetLexicon(fields []string, cfg *wglconfig.Config) error

func (*GameOptions) SetVariant

func (opts *GameOptions) SetVariant(name string) error

type Lexicon

type Lexicon struct {
	Name         string
	Distribution string
}

func (*Lexicon) ToDisplayString

func (lex *Lexicon) ToDisplayString() string

type TurnPlayer

type TurnPlayer interface {
	SetPlayerRack(playerid int, letters string) error
	SetCurrentRack(letters string) error
	NewPlacementMove(playerid int, coords string, word string) (*move.Move, error)
	NewPassMove(playerid int) (*move.Move, error)
	NewChallengeMove(playerid int) (*move.Move, error)
	NewExchangeMove(playerid int, letters string) (*move.Move, error)
	MoveFromEvent(evt *pb.GameEvent) (*move.Move, error)
	IsPlaying() bool
	ParseMove(playerid int, lowercase bool, fields []string) (*move.Move, error)
	AssignEquity(plays []*move.Move, oppRack *tilemapping.Rack)
}

TurnPlayer encapsulates all the functions needed to play a single turn of our crossword board game.

Jump to

Keyboard shortcuts

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