deck

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotEnoughCards = errors.New("not enough cards")

ErrNotEnoughCards is the error returned when there are not enough cards in the deck.

Functions

This section is empty.

Types

type Deck

type Deck struct {
	// contains filtered or unexported fields
}

Deck represents a deck of cards.

func New

func New(opts ...Option) (*Deck, error)

New creates a new deck with the given options.

func (*Deck) Cards

func (d *Deck) Cards() []card.Card

Cards returns the cards in the deck.

func (*Deck) Composition added in v0.2.0

func (d *Deck) Composition() string

Composition returns the composition of the deck.

func (*Deck) Draw

func (d *Deck) Draw(n int) ([]card.Card, error)

Draw returns n number of cards from the deck.

func (*Deck) ID

func (d *Deck) ID() string

ID returns the id of the deck.

func (*Deck) IsShuffled

func (d *Deck) IsShuffled() bool

IsShuffled returns true if the deck is shuffled.

func (*Deck) Remaining

func (d *Deck) Remaining() int

Remaining returns the cards remaining in the deck.

func (*Deck) Shuffle

func (d *Deck) Shuffle()

Shuffle shuffles the cards randomly in the deck.

type Option

type Option func(d *Deck)

Option is a function that can be used to modify a deck.

func WithCodes added in v0.2.0

func WithCodes(codes ...string) Option

WithCodes returns an option that sets the card codes of the deck.

func WithComposition added in v0.2.0

func WithComposition(comp string) Option

WithComposition returns an option that sets the composition of the deck.

func WithID

func WithID(id string) Option

WithID returns an option that sets the id of the deck.

func WithShuffled

func WithShuffled(s bool) Option

WithShuffled returns an option that sets the shuffled state of the deck.

Jump to

Keyboard shortcuts

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