Die API-Referenz stammt aus den Go-Doc-Kommentaren im Quellcode und ist auf Englisch verfasst.
package match3
import "github.com/nsgo-dev/game/pkg/match3"Übersicht
Package match3 is experimental: its API and documented formats may change in a minor release. See the API stability policy. provides deterministic match detection for grid puzzles.
Index
Typen
type Board struct {
Width, Height int
Cells []int
}Board is a rectangular deterministic match-3 grid. Zero cells are empty.
func New(width, height int, cells []int) BoardNew returns a board with a copy of cells.
func (b Board) At(x, y int) intAt returns the cell at x,y, or zero outside the board.
func (b Board) Matches() []PointMatches returns all cells belonging to horizontal or vertical runs of three or more equal non-zero pieces, sorted by row then column.
func (b *Board) Swap(a, c Point) boolSwap exchanges adjacent cells and reports whether the resulting board has a match.
type Level struct {
// Version is the level format version and must be 1.
Version int `yaml:"version"`
// Width is the number of columns and must be at least 3.
Width int `yaml:"width"`
// Height is the number of rows and must be at least 3.
Height int `yaml:"height"`
// Moves is the maximum number of moves and must be positive.
Moves int `yaml:"moves"`
// Goal is the target score or progress count and must be positive.
Goal int `yaml:"goal"`
// Cells contains one tile value for every cell in row-major order.
Cells []int `yaml:"cells"`
}Level is a validated version-one match-3 level definition.
func ParseLevel(data []byte) (Level, error)ParseLevel decodes and validates a version-one level YAML document.
func (l Level) Validate() errorValidate checks the level version, dimensions, limits, and cell count.