GitHubEmpezar

La referencia de API proviene de los comentarios de documentación de Go en el código fuente y está redactada en inglés.

package mergegame

import "github.com/nsgo-dev/game/pkg/mergegame"

Resumen

Package mergegame is experimental: its API and documented formats may change in a minor release. See the API stability policy. defines the small, deterministic data contract used by merge-game templates. A chain lists ordered tiers and their sell values.

Índice

Constantes

const FormatVersion = 1

FormatVersion is the current merge-chain YAML schema version.

Funciones

func Encode(d Document) ([]byte, error)

Encode validates d and writes its deterministic YAML representation.

Tipos

type Chain struct {
	// ID is the chain's non-empty identifier without surrounding spaces, unique within the document.
	ID string `yaml:"id"`
	// Tiers lists at least two tiers from lowest to highest, each with an ID unique within the chain.
	Tiers []Tier `yaml:"tiers"`
}

Chain describes the ordered tiers in one progression path.

type Document struct {
	// Version is the format version and must be FormatVersion.
	Version int `yaml:"version"`
	// Chains lists at least one chain, each with a unique ID.
	Chains []Chain `yaml:"chains"`
}

Document is a versioned collection of merge chains.

func Parse(data []byte) (Document, error)

Parse decodes and validates one canonical merge-chain YAML document.

func (d Document) ChainIDs() []string

ChainIDs returns chain IDs in document order.

func (d Document) Next(chainID, tierID string) (Tier, bool)

Next returns the tier immediately after tierID in chainID. It reports false when the tier is the chain's final tier or either ID is unknown.

func (d Document) SortedChainIDs() []string

SortedChainIDs returns a stable alphabetical copy of chain IDs.

func (d Document) Validate() error

Validate reports whether d has a supported version and unique valid chains and tiers.

type Tier struct {
	// ID is the tier's non-empty identifier without surrounding spaces.
	ID string `yaml:"id"`
	// Value is the tier's non-negative sell value.
	Value int `yaml:"value"`
}

Tier is one merge progression level and its value.