Documentation ¶
Index ¶
- Constants
- Variables
- func NewUUID() string
- func ReadInput() string
- type Action
- type Card
- type Deck
- type Hand
- func (h *Hand) Add(card Card)
- func (h *Hand) CanDouble() bool
- func (h *Hand) CanSplit() bool
- func (h *Hand) Clear()
- func (h *Hand) Count() int
- func (h *Hand) Hard() bool
- func (h *Hand) IsInitialHand() bool
- func (h *Hand) IsNatural() bool
- func (h *Hand) Soft() bool
- func (h *Hand) String() string
- func (h *Hand) Total() int
- type Rank
- type Result
- type Shuffler
- type Suit
Constants ¶
const ( ActionHit = iota + 1 ActionStay ActionSplit ActionDouble ActionSurrender ActionStats ActionExit ActionInvalid )
Actions a player can take.
const ( ResultWin = iota + 1 ResultLoss ResultTie ResultNone ResultInvalid )
Results of playing a hand.
Variables ¶
var ErrDeckEmpty = errors.New("deck is empty")
ErrDeckEmpty means the deck is empty.
var UseCardSymbols = false
UseCardSymbols determines whether to use the unicode card symbols for the text representation or straight text.
Functions ¶
Types ¶
type Action ¶
type Action int
Action a player can take.
func ParseAction ¶ added in v1.1.0
ParseAction will return the Action represented by the given string.
type Card ¶
type Card struct { Hidden bool // contains filtered or unexported fields }
Card represents a single card.
type Deck ¶
type Deck struct {
Cards []Card
}
Deck represents a deck of cards.
func NewDeck ¶
func NewDeck() *Deck
NewDeck creates a new deck of 52 cards. The cards are not in random order.
type Hand ¶
Hand represents a hand of cards.
func (*Hand) Hard ¶
Hard returns true if the hand is a hard hand, meaning it includes no aces or only aces that are counted as 1.
func (*Hand) IsInitialHand ¶
IsInitialHand will return true if hand only has two cards.
func (*Hand) IsNatural ¶
IsNatural will return true if this hand is a natural blackjack (21 from two cards).
func (*Hand) Soft ¶
Soft returns true if the hand is a soft hand, meaning it includes an ace that is counted as 11.
type Result ¶ added in v1.1.0
type Result int
Result of playing a hand.
func ParseResult ¶ added in v1.1.0
ParseResult will return the Result represented by the given string.