GitHubLoslegen

Die API-Referenz stammt aus den Go-Doc-Kommentaren im Quellcode und ist auf Englisch verfasst.

package deck

import "github.com/nsgo-dev/game/pkg/cards/deck"

Übersicht

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.

Index

Variablen

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.

Typen

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) *Deck

New creates a deck from cards.

func (d *Deck) Discard(id string) error

Discard moves the first card in hand with id to the discard pile.

func (d *Deck) Draw(n int) []Card

Draw draws cards from the deck.

func (d *Deck) EndTurn()

EndTurn applies end-of-turn pile transitions.

func (d *Deck) Exhaust(id string) error

Exhaust moves the first card in hand with id to the exhaust pile, out of future draws.

func (d *Deck) Hand() []Card

Hand 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.