cards

package
v0.0.0-...-48ab5c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const FullDeckSize = 52
View Source
const ShortDeckSize = 36

Variables

Functions

This section is empty.

Types

type ByCombination

type ByCombination []Combination

func (ByCombination) Len

func (r ByCombination) Len() int

func (ByCombination) Less

func (r ByCombination) Less(i, j int) bool

func (ByCombination) Swap

func (r ByCombination) Swap(i, j int)

type ByCombinationReversed

type ByCombinationReversed []Combination

func (ByCombinationReversed) Len

func (r ByCombinationReversed) Len() int

func (ByCombinationReversed) Less

func (r ByCombinationReversed) Less(i, j int) bool

func (ByCombinationReversed) Swap

func (r ByCombinationReversed) Swap(i, j int)

type ByFace

type ByFace []Card

sort.Interface implementation for handy sorting

func (ByFace) Len

func (r ByFace) Len() int

func (ByFace) Less

func (r ByFace) Less(i, j int) bool

func (ByFace) Swap

func (r ByFace) Swap(i, j int)

type ByFaceReversed

type ByFaceReversed []Card

func (ByFaceReversed) Len

func (r ByFaceReversed) Len() int

func (ByFaceReversed) Less

func (r ByFaceReversed) Less(i, j int) bool

func (ByFaceReversed) Swap

func (r ByFaceReversed) Swap(i, j int)

type Card

type Card struct {
	// contains filtered or unexported fields
}

func NewCard

func NewCard(face Face, suit Suit) (*Card, error)

func (Card) Face

func (c Card) Face() Face

func (Card) Suit

func (c Card) Suit() Suit

type Combination

type Combination struct {
	// contains filtered or unexported fields
}

func CombinationsOf

func CombinationsOf(cards []Card, combinationStrengths []CombinationType, shortDeck bool) ([]Combination, error)

func NewCombination

func NewCombination(cards []Card, combinationStrengths []CombinationType, shortDeck bool) (*Combination, error)

func NewDefaultCombination

func NewDefaultCombination(cards []Card) (*Combination, error)

func NewShortDeckCombination

func NewShortDeckCombination(cards []Card) (*Combination, error)

func StrongestCombinationOf

func StrongestCombinationOf(cards []Card, combinationStrengths []CombinationType, shortDeck bool) (*Combination, error)

func (Combination) AllCards

func (r Combination) AllCards() []Card

func (Combination) CombinationStrengths

func (r Combination) CombinationStrengths() []CombinationType

func (Combination) HighestCardFace

func (r Combination) HighestCardFace() Face

func (Combination) Kickers

func (r Combination) Kickers() []Card

func (Combination) Less

func (r Combination) Less(other Combination) bool

func (Combination) MainCard

func (r Combination) MainCard() Face

func (Combination) More

func (r Combination) More(other Combination) bool

func (Combination) SecondaryCard

func (r Combination) SecondaryCard() *Face

func (Combination) Tie

func (r Combination) Tie(other Combination) bool

func (Combination) Type

func (r Combination) Type() CombinationType

TODO Known issue: This function will perform ok with short-deck vs classic since the only difference is flush/full house strength since it's impossible to have both at the same time. However, if other custom rules for strength will be passed (as design suggests) there can be issues with the order of combination type resolving. For some reason I couldn't fix it right away, so I will postpone resolving this issue if it will come up some time after

type CombinationType

type CombinationType int
const (
	HighCard CombinationType = iota
	Pair
	TwoPair
	ThreeOfAKind
	Straight
	Flush
	FullHouse
	FourOfAKind
	StraightFlush
)

type Deck

type Deck struct {
	// contains filtered or unexported fields
}

func NewDeck

func NewDeck(cards []Card) (*Deck, error)

func NewDeckWithoutValidation

func NewDeckWithoutValidation(cards []Card) Deck

func NewFullDeck

func NewFullDeck() Deck

func NewShortDeck

func NewShortDeck() Deck

func (*Deck) CardIsDrawn

func (d *Deck) CardIsDrawn(card Card) bool

func (*Deck) CardIsLeft

func (d *Deck) CardIsLeft(card Card) bool

func (*Deck) Collect

func (d *Deck) Collect()

func (*Deck) CollectAndShuffle

func (d *Deck) CollectAndShuffle()

func (*Deck) ContainsCard

func (d *Deck) ContainsCard(card Card) bool

func (*Deck) Draw

func (d *Deck) Draw() (*Card, error)

func (Deck) IsEmpty

func (d Deck) IsEmpty() bool

func (*Deck) MoveToDrawn

func (d *Deck) MoveToDrawn(card Card) error

func (*Deck) Shuffle

func (d *Deck) Shuffle()

func (Deck) Size

func (d Deck) Size() int

type Face

type Face int
const (
	Two Face = iota
	Three
	Four
	Five
	Six
	Seven
	Eight
	Nine
	Ten
	Jack
	Queen
	King
	Ace
)

type Suit

type Suit int
const (
	Clubs Suit = iota
	Diamonds
	Spades
	Hearts
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL