Documentation ¶
Index ¶
Constants ¶
const ( // DeckSize of a normal deck of cards. DeckSize = int(SuitsCnt) * int(RanksCnt) )
Variables ¶
This section is empty.
Functions ¶
func DefaultComparator ¶
DefaultComparator is the default comparator used for sorting a deck of cards.
Types ¶
type Card ¶
Card represents a playing card from a deck of cards. It contains a rank (e.g. Ace) and a suit (e.g. Clovers). It also contains a boolean flag denoting this card as a joker.
type Comparator ¶
Comparator is used to sort a deck of cards based on a user-defined comparator.
type Deck ¶
type Deck struct {
Cards []Card
}
Deck encapsulates a normal deck of cards and defines some operations on them.
func New ¶
New deck of cards, based on the options provided. In case none are passed, a sorted default deck of cards (without jokers) will be returned.
func (*Deck) Draw ¶
Draw a card from the deck. The drawn card is returned and removed from the deck.
func (*Deck) InsertBottom ¶
InsertBottom puts the given cards at the bottom of the deck.
type Option ¶
Option is a function alias used for constructing a functional-options constructor for a deck.
func Shuffle ¶
func Shuffle() Option
Shuffle is a functional option for shuffling the deck in a random way.
func ShuffleWithSeed ¶
ShuffleWithSeed is a functional option for shuffling the deck based on a random seed.
func Sort ¶
func Sort(comp Comparator) Option
Sort is a functional option for sorting the deck based on a user-defined comparator.
func WithJokers ¶
WithJokers is a functional option for specifying how many jokers to include.