Documentation ¶
Index ¶
Constants ¶
const (
DeckCapacity = int(SuitsTotalCount) * int(ValuesTotalCount)
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
func ParseCard ¶
ParseCard will parse the given string into a card object from short ("ad") or long ("ace of diamonds") forms
func (Card) ShortString ¶
ShortString will return something like "ah"
type Deck ¶
type Deck struct { Cards []Card // contains filtered or unexported fields }
func DeckDeserialize ¶
func NewDeck ¶
func NewDeck() *Deck
NewDeck initializes the deck with 52 unique cards in sorted order
func (*Deck) DealCard ¶
DealCard removes the top card from the deck (subtracts it from the slice's front) and returns it
func (*Deck) ReturnCard ¶
ReturnCard adds the given card to the deck (at the end of the slice)
type Suit ¶
type Suit uint8
Suit represents one of the 4 card categories (Clubs / Hearts / Diamonds / Spades)
const ( SuitClubs Suit = iota SuitHearts SuitDiamonds SuitSpades SuitsTotalCount // the total number of suits )
Suit values
func (Suit) ShortString ¶
Short string representation of the suit, used for persistence
type Value ¶
type Value uint8
Value represents one of the 13 card face values (Ace - King)
const ( ValueAce Value = iota ValueTwo ValueThree ValueFour ValueFive ValueSix ValueSeven ValueEight ValueNine ValueTen ValueJack ValueQueen ValueKing ValuesTotalCount // a marker for the end of this enum )
Value values
func ParseValue ¶
ParseValue will parse the given card value string in short (a) or long (ace) forms