A referência da API é gerada a partir dos comentários de documentação Go no código-fonte e está escrita em inglês.
package deck
import "github.com/nsgo-dev/game/pkg/cards/deck"Visão geral
Package deck provides deterministic draw, hand, discard, and exhaust piles.
The package is experimental: its API and documented formats may change in a minor release. See the API stability policy.
Índice
Variáveis
var ErrEmpty = errors.New("deck: no cards available")ErrEmpty reports that neither the draw pile nor the discard pile has a card left. Draw does not return it: it returns fewer cards than asked for instead.
Tipos
type Card struct {
ID string
Cost int
Keywords map[string]bool
}Card identifies a card in a deck.
type Deck struct {
// contains filtered or unexported fields
}Deck manages deterministic draw and discard piles.
func New(cards []Card, seed uint64, handLimit int) *DeckNew creates a deck from cards.
func (d *Deck) Discard(id string) errorDiscard moves the first card in hand with id to the discard pile.
func (d *Deck) EndTurn()EndTurn applies end-of-turn pile transitions.
func (d *Deck) Exhaust(id string) errorExhaust moves the first card in hand with id to the exhaust pile, out of future draws.
func (d *Deck) Hand() []CardHand returns a copy of the cards currently held.
func (d *Deck) Piles() (draw, discard, exhaust []Card)Piles returns copies of the draw, discard, and exhaust piles.