cards

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCardsInDeck = errors.New("no cards in deck")

Functions

func GetCardID

func GetCardID(name string) int

GetCardID return combination id

func GetCardName

func GetCardName(id int) string

GetCardName return combination name

func GetCardsIDs

func GetCardsIDs(names []string) []int

GetCardsIDs return cards ids by names

func GetCardsNames

func GetCardsNames(ids []int) []string

GetCardsNames return cards names by id

func GetCombinationID

func GetCombinationID(name string) int

GetCombinationID return combination id

func GetCombinationName

func GetCombinationName(id int) string

GetCombinationName return combination name

Types

type BinaryEvaluation

type BinaryEvaluation struct{}

BinaryEvaluation evaluation by binary cards

func (BinaryEvaluation) Execute

func (b BinaryEvaluation) Execute(cards []int) *Combination

Execute execute evaluation

type Combination

type Combination struct {
	Combination   int
	Weight        int
	KickersWeight int
	Cards         []int // always 5 cards
	Kickers       []int // from 0 to 4
}

Combination describe combination of user

func (*Combination) CalculateKicker

func (c *Combination) CalculateKicker(cardSet set.GenericDataSet[int])

CalculateKicker calculate combination kicker

func (*Combination) Score

func (c *Combination) Score() int

Score calculate score of combination

type Deck

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

Deck contains cards from current game

func NewDeck

func NewDeck() *Deck

NewDeck return new deck

func (*Deck) GetRandomCard

func (d *Deck) GetRandomCard() (int, error)

GetRandomCard return random card, and remove from deck

func (*Deck) GetTopCards

func (d *Deck) GetTopCards(n int) ([]int, error)

GetTopCards return top cards, and remove from deck

func (*Deck) Shuffle

func (d *Deck) Shuffle()

Shuffle shuffle deck

func (*Deck) Top

func (d *Deck) Top() (card int, err error)

Top return card from top

Jump to

Keyboard shortcuts

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