ast

package
v0.0.0-...-1ce2342 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ast declares types used for webpbn format.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnmarshal = errors.New("can't unmarshal")

ErrUnmarshal unmarshalling error.

Functions

This section is empty.

Types

type Char

type Char rune

Char defines a color unique character.

func (Char) MarshalText

func (c Char) MarshalText() ([]byte, error)

MarshalText encodes the character into UTF-8-encoded text and returns the result.

func (*Char) UnmarshalText

func (c *Char) UnmarshalText(b []byte) error

UnmarshalText decodes the character from UTF-8-encoded text.

type Clue

type Clue struct {
	Type  ClueType `xml:"type,attr"`
	Lines []Line   `xml:"line"`
}

Clue defines a clue used in the puzzle.

type ClueType

type ClueType string

ClueType declares a type of clue.

const (
	// Columns used for a clue that stores columns.
	Columns ClueType = "columns"

	// Rows used for a clue that stores rows.
	Rows ClueType = "rows"
)

type Clues

type Clues []Clue

Clues collection of clues.

func (Clues) GetByType

func (c Clues) GetByType(t ClueType) (*Clue, bool)

GetByType returns a clue by his type.

type Color

type Color struct {
	Name string `xml:"name,attr"`
	Char Char   `xml:"char,attr"`
	Hex  string `xml:",chardata"`
}

Color defines a color name used in the puzzle.

type Colors

type Colors []Color

Colors collection of colors.

func (Colors) GetByChar

func (c Colors) GetByChar(char Char) (*Color, bool)

GetByChar returns a color from the collection by his character.

func (Colors) GetByName

func (c Colors) GetByName(name string) (*Color, bool)

GetByName returns a color from the collection by his name.

type Count

type Count struct {
	Count int    `xml:",chardata"`
	Color string `xml:"color,attr,omitempty"`
}

Count defines line counts.

type Image

type Image [][]Char

Image defines solution image.

func (Image) MarshalText

func (i Image) MarshalText() (b []byte, err error)

MarshalText encodes the image into UTF-8-encoded text and returns the result.

func (*Image) UnmarshalText

func (i *Image) UnmarshalText(text []byte) error

UnmarshalText decodes the image from UTF-8-encoded text.

type Line

type Line struct {
	Counts []Count `xml:"count"`
}

Line defines clue line.

type Puzzle

type Puzzle struct {
	Type            PuzzleType `xml:"type,attr"`
	DefaultColor    string     `xml:"defaultcolor,attr,omitempty"`
	BackgroundColor string     `xml:"backgroundcolor,attr,omitempty"`
	Source          string     `xml:"source,omitempty"`
	ID              string     `xml:"id,omitempty"`
	Author          string     `xml:"author,omitempty"`
	AuthorID        string     `xml:"authorid,omitempty"`
	Copyright       string     `xml:"copyright,omitempty"`
	Description     string     `xml:"description,omitempty"`
	Colors          Colors     `xml:"color"`
	Clues           Clues      `xml:"clues"`
	Solution        *Solution  `xml:"solution,omitempty"`
}

Puzzle a puzzle in the set of puzzles.

type PuzzleSet

type PuzzleSet struct {
	XMLName xml.Name `xml:"puzzleset"`
	Puzzles []Puzzle `xml:"puzzle"`
}

PuzzleSet the root structure of the document. Includes all puzzles.

type PuzzleType

type PuzzleType string

PuzzleType declares a type of the puzzle.

const Grid PuzzleType = "grid"

Grid used for a puzzle where cells are square and there will be a set of row clues and a set of column clue.

type Solution

type Solution struct {
	Type  SolutionType `xml:"type,attr"`
	Image Image        `xml:"image"`
}

Solution defines puzzle solution.

type SolutionType

type SolutionType string

SolutionType declares a type of the solution.

const Goal SolutionType = "goal"

Goal used for the goal solution intended by the designer of the puzzle.

Jump to

Keyboard shortcuts

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