Documentation
¶
Overview ¶
Package game defines the plugin interface for puzzle games.
Index ¶
- Variables
- func DebugHeader(title string, rows [][2]string) string
- func DebugTable(heading string, headers []string, rows [][]string) string
- func Register(name string, fn func([]byte) (Gamer, error))
- func TitleBarView(gameName, modeName string, solved bool) string
- type BaseMode
- type Category
- type Cursor
- type CursorKeyMap
- type Gamer
- type HelpToggleMsg
- type Mode
- type Spawner
Constants ¶
This section is empty.
Variables ¶
var DefaultCursorKeyMap = CursorKeyMap{ Up: key.NewBinding( key.WithKeys("k", "up", "w"), key.WithHelp("↑/w/k", "Up"), ), Down: key.NewBinding( key.WithKeys("j", "down", "s"), key.WithHelp("↓/s/j", "Down"), ), Left: key.NewBinding( key.WithKeys("h", "left", "a"), key.WithHelp("←/a/h", "Left"), ), Right: key.NewBinding( key.WithKeys("l", "right", "d"), key.WithHelp("→/d/l", "Right"), ), }
DefaultCursorKeyMap provides the standard cursor movement bindings.
var Registry = map[string]func([]byte) (Gamer, error){}
Registry maps game type names to their import functions.
Functions ¶
func DebugHeader ¶
DebugHeader returns the markdown heading and property table header for debug info. rows is a list of [key, value] pairs for the "Game State" table.
func DebugTable ¶
DebugTable returns a markdown table section with a heading and arbitrary columns. headers is the column names, rows is a list of row values.
func TitleBarView ¶
TitleBarView renders a title bar with the game name, mode name, and optional solved badge.
Types ¶
type BaseMode ¶
type BaseMode struct {
// contains filtered or unexported fields
}
BaseMode provides the common title/description fields and the three Mode-interface methods so that concrete mode structs can embed it instead of duplicating boilerplate.
func NewBaseMode ¶
NewBaseMode creates a BaseMode with the given title and description.
func (BaseMode) Description ¶
func (BaseMode) FilterValue ¶
type Category ¶
Category groups related game modes under a heading in the menu.
func (Category) Description ¶
func (Category) FilterValue ¶
type CursorKeyMap ¶
CursorKeyMap defines the shared cursor movement key bindings.
type Gamer ¶
type Gamer interface {
GetDebugInfo() string
GetFullHelp() [][]key.Binding
GetSave() ([]byte, error)
IsSolved() bool
SetTitle(string) Gamer
Init() tea.Cmd
View() string
Update(msg tea.Msg) (Gamer, tea.Cmd)
}
Gamer is the interface that an active game instance must implement.
type HelpToggleMsg ¶
type HelpToggleMsg struct{ Show bool }
HelpToggleMsg is sent from the root model to games when the user toggles the full help display with Ctrl+H.