Documentation
¶
Overview ¶
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Package cards provides a comprehensive implementation of playing card types and operations for a standard 52-card French-suited deck.
Index ¶
- Constants
- func Asc(a, b Card) bool
- func Desc(a, b Card) bool
- func Equal(hands int) func(int) bool
- func FisherYates(r rand.Rand) func(Deck) Deck
- func Num(num int) func(int) bool
- func RankAsc(a, b Card) bool
- func RankDesc(a, b Card) bool
- func Size(hands, size int) func(int) bool
- func SuitAsc(a, b Card) bool
- func SuitDesc(a, b Card) bool
- type Card
- func (c Card) MarshalJSON() ([]byte, error)
- func (c Card) MarshalText() ([]byte, error)
- func (c Card) Name() string
- func (c Card) Rank() Rank
- func (c *Card) Scan(src any) error
- func (c Card) String() string
- func (c Card) Suit() Suit
- func (c Card) Symbol() rune
- func (c *Card) UnmarshalJSON(data []byte) error
- func (c *Card) UnmarshalText(data []byte) error
- func (c Card) Value() (driver.Value, error)
- type Deck
- type Hand
- type ParseErr
- type Rank
- func (r Rank) Card(s Suit) Card
- func (r Rank) MarshalJSON() ([]byte, error)
- func (r Rank) MarshalText() ([]byte, error)
- func (r Rank) Name() string
- func (r *Rank) Scan(src any) error
- func (r Rank) String() string
- func (r Rank) Symbol() rune
- func (r *Rank) UnmarshalJSON(data []byte) error
- func (r *Rank) UnmarshalText(data []byte) error
- func (r Rank) Value() (driver.Value, error)
- type Suit
- func (s Suit) Card(r Rank) Card
- func (s Suit) MarshalJSON() ([]byte, error)
- func (s Suit) MarshalText() ([]byte, error)
- func (s Suit) Name() string
- func (s *Suit) Scan(src any) error
- func (s Suit) String() string
- func (s Suit) Symbol() rune
- func (s *Suit) UnmarshalJSON(data []byte) error
- func (s *Suit) UnmarshalText(data []byte) error
- func (s Suit) Value() (driver.Value, error)
Constants ¶
const (
CA, C2, C3, C4, C5, C6, C7, C8, C9, CT, CJ, CQ, CK = Card(0), Card(1), Card(2), Card(3), Card(4), Card(5), Card(6), Card(7), Card(8), Card(9), Card(10), Card(11), Card(12)
DA, D2, D3, D4, D5, D6, D7, D8, D9, DT, DJ, DQ, DK = Card(13), Card(14), Card(15), Card(16), Card(17), Card(18), Card(19), Card(20), Card(21), Card(22), Card(23), Card(24), Card(25)
HA, H2, H3, H4, H5, H6, H7, H8, H9, HT, HJ, HQ, HK = Card(26), Card(27), Card(28), Card(29), Card(30), Card(31), Card(32), Card(33), Card(34), Card(35), Card(36), Card(37), Card(38)
SA, S2, S3, S4, S5, S6, S7, S8, S9, ST, SJ, SQ, SK = Card(39), Card(40), Card(41), Card(42), Card(43), Card(44), Card(45), Card(46), Card(47), Card(48), Card(49), Card(50), Card(51)
)
const ( ErrSyntax = cardErr("invalid syntax") ErrRange = cardErr("input out of range") )
const ( Ace = Rank(0) // 'A' "Ace" Two = Rank(1) // '2' "Two" Three = Rank(2) // '3' "Three" Four = Rank(3) // '4' "Four" Five = Rank(4) // '5' "Five" Six = Rank(5) // '6' "Six" Seven = Rank(6) // '7' "Seven" Eight = Rank(7) // '8' "Eight" Nine = Rank(8) // '9' "Nine" Ten = Rank(9) // 'T' "Ten" Jack = Rank(10) // 'J' "Jack" Queen = Rank(11) // 'Q' "Queen" King = Rank(12) // 'K' "King" )
const ( Clubs = Suit(0) // '♣' "Clubs" Diamonds = Suit(1) // '♦' "Diamonds" Hearts = Suit(2) // '♥' "Hearts" Spades = Suit(3) // '♠' "Spades" )
Variables ¶
This section is empty.
Functions ¶
func FisherYates ¶
FisherYates shuffle algorithm, see https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
Types ¶
type Card ¶
type Card uint8
Card in a standard 52-card deck of French-suited playing cards.
func (Card) MarshalJSON ¶ added in v1.1.0
MarshalJSON implements json.Marshaler.
func (Card) MarshalText ¶ added in v1.1.0
MarshalText implements encoding.TextMarshaler.
func (*Card) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON implements json.Unmarshaler.
func (*Card) UnmarshalText ¶ added in v1.1.0
UnmarshalText implements encoding.TextUnmarshaler.
type Deck ¶
type Deck [52]Card
Deck of 52 cards.
func (Deck) ShuffleWith ¶
ShuffleWith the provided algorithm.
type Hand ¶
type Hand []Card
Hand of cards.
func (Hand) Find ¶
Find the index of the first instance of the provided card, or false if not in the hand.
type Rank ¶
type Rank uint8
Rank of a card (suit independant value).
func (Rank) MarshalJSON ¶ added in v1.1.0
MarshalJSON implements json.Marshaler.
func (Rank) MarshalText ¶ added in v1.1.0
MarshalText implements encoding.TextMarshaler.
func (*Rank) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON implements json.Unmarshaler.
func (*Rank) UnmarshalText ¶ added in v1.1.0
UnmarshalText implements encoding.TextUnmarshaler.
type Suit ¶
type Suit uint8
Suit of a Card (one of ♣, ♦, ♥, ♠).
func (Suit) MarshalJSON ¶ added in v1.1.0
MarshalJSON implements json.Marshaler.
func (Suit) MarshalText ¶ added in v1.1.0
MarshalText implements encoding.TextMarshaler.
func (*Suit) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON implements json.Unmarshaler.
func (*Suit) UnmarshalText ¶ added in v1.1.0
UnmarshalText implements encoding.TextUnmarshaler.