cards

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: BSD-3-Clause Imports: 2 Imported by: 3

README

cards

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Card

type Card struct {
	Suit Suit
	Rank Rank
}

Card represents a playing card with a suit and rank.

func (Card) String

func (c Card) String() string

String returns the string representation of the Card.

type CardSet

type CardSet interface {
	Shuffle()
	String() string
	Draw() Card
}

CardSet represents a set of cards that can be shuffled.

type Deck

type Deck []Card

Deck represents a standard 52 card deck.

func NewDeck

func NewDeck() Deck

NewDeck creates and returns a new standard 52 card deck.

func (*Deck) Draw

func (d *Deck) Draw() Card

Draw removes and returns the top card from the deck.

func (Deck) Shuffle

func (d Deck) Shuffle()

Shuffle shuffles the deck of cards in place.

func (Deck) String

func (d Deck) String() string

String returns the string representation of the Deck.

type Rank

type Rank int

Rank represents one of 13 standard card ranks.

const (
	Ace Rank
	Two
	Three
	Four
	Five
	Six
	Seven
	Eight
	Nine
	Ten
	Jack
	Queen
	King
)

func (Rank) String

func (r Rank) String() string

String returns the string representation of the Rank.

type Shoe

type Shoe []Card

Shoe represents a collection of multiple decks of cards.

func NewShoe

func NewShoe(numDecks int) Shoe

NewShoe creates and returns a new shoe containing the specified number of decks.

func (*Shoe) Draw

func (s *Shoe) Draw() Card

Draw removes and returns the top card from the shoe.

func (Shoe) Shuffle

func (s Shoe) Shuffle()

Shuffle shuffles the shoe of cards in place.

func (Shoe) String

func (s Shoe) String() string

String returns the string representation of the Shoe.

type Suit

type Suit int

Suit represents the french suit of a standard 52 card deck.

const (
	Diamonds Suit
	Clubs
	Hearts
	Spades
)

func (Suit) String

func (s Suit) String() string

Jump to

Keyboard shortcuts

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