Documentation ¶
Overview ¶
Package cards provides playing cards.
Index ¶
- Constants
- Variables
- type Card
- type CardFace
- type CardSuit
- type Cards
- func (c Cards) Contains(card Card) bool
- func (c Cards) Copy() Cards
- func (c Cards) Count(card Card) int
- func (c Cards) Equal(cards Cards) bool
- func (c Cards) High() Card
- func (c Cards) Len() int
- func (c Cards) Less(i, j int) bool
- func (c Cards) Low() Card
- func (c Cards) Remove(i int) Cards
- func (c Cards) Reverse() Cards
- func (c Cards) Sort() Cards
- func (c Cards) Swap(i, j int)
- type Deck
Constants ¶
const ( SymbolHearts = "♥" SymbolDiamonds = "♦" SymbolClubs = "♣" SymbolSpades = "♠" SymbolJoker = "!" )
Card symbols
const Invalid = "?"
Invalid is the text shown when a valid face or suit is not found.
Variables ¶
var AllFaces = []CardFace{ FaceAce, Face2, Face3, Face4, Face5, Face6, Face7, Face8, Face9, Face10, FaceJack, FaceQueen, FaceKing, FaceJoker, }
AllFaces is a slice of all faces.
var AllSuits = []CardSuit{ SuitHearts, SuitDiamonds, SuitClubs, SuitSpades, SuitJoker, }
AllSuits is a slice of all suits.
var StandardCards = Cards{ Card{FaceAce, SuitHearts}, Card{Face2, SuitHearts}, Card{Face3, SuitHearts}, Card{Face4, SuitHearts}, Card{Face5, SuitHearts}, Card{Face6, SuitHearts}, Card{Face7, SuitHearts}, Card{Face8, SuitHearts}, Card{Face9, SuitHearts}, Card{Face10, SuitHearts}, Card{FaceJack, SuitHearts}, Card{FaceQueen, SuitHearts}, Card{FaceKing, SuitHearts}, Card{FaceAce, SuitDiamonds}, Card{Face2, SuitDiamonds}, Card{Face3, SuitDiamonds}, Card{Face4, SuitDiamonds}, Card{Face5, SuitDiamonds}, Card{Face6, SuitDiamonds}, Card{Face7, SuitDiamonds}, Card{Face8, SuitDiamonds}, Card{Face9, SuitDiamonds}, Card{Face10, SuitDiamonds}, Card{FaceJack, SuitDiamonds}, Card{FaceQueen, SuitDiamonds}, Card{FaceKing, SuitDiamonds}, Card{FaceAce, SuitClubs}, Card{Face2, SuitClubs}, Card{Face3, SuitClubs}, Card{Face4, SuitClubs}, Card{Face5, SuitClubs}, Card{Face6, SuitClubs}, Card{Face7, SuitClubs}, Card{Face8, SuitClubs}, Card{Face9, SuitClubs}, Card{Face10, SuitClubs}, Card{FaceJack, SuitClubs}, Card{FaceQueen, SuitClubs}, Card{FaceKing, SuitClubs}, Card{FaceAce, SuitSpades}, Card{Face2, SuitSpades}, Card{Face3, SuitSpades}, Card{Face4, SuitSpades}, Card{Face5, SuitSpades}, Card{Face6, SuitSpades}, Card{Face7, SuitSpades}, Card{Face8, SuitSpades}, Card{Face9, SuitSpades}, Card{Face10, SuitSpades}, Card{FaceJack, SuitSpades}, Card{FaceQueen, SuitSpades}, Card{FaceKing, SuitSpades}, }
StandardCards is a slice of standard cards.
var StandardFaces = []CardFace{ FaceAce, Face2, Face3, Face4, Face5, Face6, Face7, Face8, Face9, Face10, FaceJack, FaceQueen, FaceKing, }
StandardFaces is a slice of all faces except Jokers.
var StandardSuits = []CardSuit{ SuitHearts, SuitDiamonds, SuitClubs, SuitSpades, }
StandardSuits is a slice of all card suits except Jokers.
Functions ¶
This section is empty.
Types ¶
type Card ¶
Card defines a playing card with a face and suit.
func (Card) Identifier ¶
Identifier returns a machine-readable representation of a card.
func (*Card) UnmarshalJSON ¶
UnmarshalJSON unmarshals a Card.
type CardFace ¶
type CardFace int
CardFace defines a card face.
const ( FaceAce CardFace = 1 Face2 CardFace = 2 Face3 CardFace = 3 Face4 CardFace = 4 Face5 CardFace = 5 Face6 CardFace = 6 Face7 CardFace = 7 Face8 CardFace = 8 Face9 CardFace = 9 Face10 CardFace = 10 FaceJack CardFace = 11 FaceQueen CardFace = 12 FaceKing CardFace = 13 FaceJoker CardFace = 14 )
Card faces
type CardSuit ¶
type CardSuit int
CardSuit defines a card suit.
type Cards ¶
type Cards []Card
Cards is a slice of Cards.
type Deck ¶
type Deck struct { Cards Cards // contains filtered or unexported fields }
Deck defines a playing card deck containing any number of cards.
func NewDeck ¶
NewDeck initializes a deck of cards. A seed value of 0 is replaced with the current time in nanoseconds.