spellpuzzle

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 19 Imported by: 0

README

Spell Puzzle

Connect letters from a fixed bank to reveal board words in a crossword layout. Valid extra words are counted as bonus words.

How to Play

Build a word from the allowed letters. If the word is on the board, it reveals in the crossword. If it is a valid TWL06 word but not on the board, it counts as a bonus word instead.

Controls

Key Action
A-Z Type letters from the active bank
1 Shuffle the visible bank order
Enter Submit the active word
Backspace Delete the last letter
Mouse drag Build and submit a word from the bank

Modes

Mode Bank Letters Board Words Bonus Minimum
Beginner 6 4 3
Easy 7 6 4
Medium 8 8 6
Hard 9 9 8

Quick Start

puzzletea new spell-puzzle beginner
puzzletea new spell easy

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyMap = KeyMap{
	Left: key.NewBinding(
		key.WithKeys("left", "a", "h"),
		key.WithHelp("left", "Prev letter"),
	),
	Right: key.NewBinding(
		key.WithKeys("right", "d", "l"),
		key.WithHelp("right", "Next letter"),
	),
	Shuffle: key.NewBinding(
		key.WithKeys("1"),
		key.WithHelp("1", "Shuffle letters"),
	),
	Submit: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "Submit word"),
	),
	Back: key.NewBinding(
		key.WithKeys("backspace"),
		key.WithHelp("bkspc", "Delete"),
	),
}
View Source
var Definition = puzzle.NewDefinition(puzzle.DefinitionSpec{
	Name:         "Spell Puzzle",
	Description:  "Connect letters to fill a crossword with bonus anagrams.",
	Aliases:      []string{"spell", "spellpuzzle"},
	Modes:        ModeDefinitions,
	DailyModeIDs: puzzle.SelectModeIDsByIndex(ModeDefinitions, 0),
})
View Source
var HelpContent string
View Source
var ModeDefinitions = gameentry.BuildModeDefs(Modes)
View Source
var Modes = []game.Mode{
	NewMode("Beginner", "6 letters, 4 board words, gentle intro.", 6, 4, 3),
	NewMode("Easy", "7 letters, 6 board words, balanced start.", 7, 6, 4),
	NewMode("Medium", "8 letters, 8 board words, denser layout.", 8, 8, 6),
	NewMode("Hard", "9 letters, 9 board words, largest launch board.", 9, 9, 8),
}
View Source
var PDFPrintAdapter = printAdapter{}

Functions

func New

func New(mode SpellPuzzleMode, puzzle GeneratedPuzzle) (game.Gamer, error)

Types

type GeneratedPuzzle

type GeneratedPuzzle struct {
	Bank        string
	Placements  []WordPlacement
	BonusWords  []string
	AllowedWord []string
}

func GeneratePuzzle

func GeneratePuzzle(mode SpellPuzzleMode) (GeneratedPuzzle, error)

func GeneratePuzzleSeeded

func GeneratePuzzleSeeded(mode SpellPuzzleMode, rng *rand.Rand) (GeneratedPuzzle, error)

type KeyMap

type KeyMap struct {
	Left    key.Binding
	Right   key.Binding
	Shuffle key.Binding
	Submit  key.Binding
	Back    key.Binding
}

type Model

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

func ImportModel

func ImportModel(data []byte) (*Model, error)

func (Model) GetDebugInfo

func (m Model) GetDebugInfo() string

func (Model) GetFullHelp

func (m Model) GetFullHelp() [][]key.Binding

func (Model) GetSave

func (m Model) GetSave() ([]byte, error)

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) IsSolved

func (m Model) IsSolved() bool

func (Model) Reset

func (m Model) Reset() game.Gamer

func (Model) SetTitle

func (m Model) SetTitle(t string) game.Gamer

func (Model) Update

func (m Model) Update(msg tea.Msg) (game.Gamer, tea.Cmd)

func (Model) View

func (m Model) View() string

type Orientation

type Orientation int
const (
	Horizontal Orientation = iota
	Vertical
)

type Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
}

type Save

type Save struct {
	ModeTitle    string          `json:"mode_title"`
	Bank         string          `json:"bank"`
	BankColors   []int           `json:"bank_colors,omitempty"`
	Placements   []WordPlacement `json:"placements"`
	BonusWords   []string        `json:"bonus_words"`
	Trace        []int           `json:"trace"`
	BankCursor   int             `json:"bank_cursor"`
	Solved       bool            `json:"solved"`
	Feedback     feedback        `json:"feedback"`
	ShowFullHelp bool            `json:"show_full_help"`
}

type SpellPuzzleMode

type SpellPuzzleMode struct {
	game.BaseMode
	BankSize       int
	BoardWordCount int
	MinBonusWords  int
}

func NewMode

func NewMode(title, description string, bankSize, boardWords, minBonusWords int) SpellPuzzleMode

func (SpellPuzzleMode) Spawn

func (m SpellPuzzleMode) Spawn() (game.Gamer, error)

func (SpellPuzzleMode) SpawnSeeded

func (m SpellPuzzleMode) SpawnSeeded(rng *rand.Rand) (game.Gamer, error)

type WordPlacement

type WordPlacement struct {
	Text        string      `json:"text"`
	Start       Position    `json:"start"`
	Orientation Orientation `json:"orientation"`
	Found       bool        `json:"found"`
}

func (WordPlacement) Positions

func (w WordPlacement) Positions() []Position

Jump to

Keyboard shortcuts

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