Documentation
¶
Overview ¶
Package cards provides a compact, zero-allocation representation of a standard 52-card deck with deterministic and cryptographic shuffles, sequential dealing, and convenient helpers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card uint8
Card is a compact value type encoding a card's suit and rank.
type Deck ¶
type Deck struct {
// contains filtered or unexported fields
}
Deck represents a 52-card deck with an internal cursor used for sequential dealing via Next.
func NewShuffledDeck ¶
NewShuffledDeck returns a new deck that has been shuffled using the provided seed. Using the same seed yields the same card order.
func (*Deck) IsExhausted ¶
IsExhausted reports whether all 52 cards have been dealt.
func (*Deck) Next ¶
Next deals the next card from the deck. The second return value is true if a card was returned; it becomes false only after all 52 cards have been dealt.
func (*Deck) Reset ¶
func (d *Deck) Reset()
Reset restores the deck to the ordered state (A♥..K♠), and resets the dealing cursor to the beginning.
func (*Deck) Shuffle ¶
Shuffle randomizes the order of cards using the provided seed. Shuffles are deterministic for a given seed. The dealing cursor is reset.
func (*Deck) ShuffleCrypto ¶
ShuffleCrypto shuffles the deck using crypto/rand for randomness.
func (*Deck) ShuffleRandom ¶
func (d *Deck) ShuffleRandom()
ShuffleRandom shuffles the deck using a time-based seed.
type Rank ¶
type Rank uint8
Rank represents the face value of a card from Ace (low) through King (high).