poker

package
v0.0.0-...-7d29c7d Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MIN_SPACE = 16
)

Functions

func CompareTwoBestFive

func CompareTwoBestFive(firstFive, secondFive Cards) (int, error)

CompareTwoBestFive compares two hands returns 1 if first hand best, 2 if second hand best and 0 if hands are the same (in evaluation, not necessarily identical) errConstant if error

Types

type ByNumber

type ByNumber Cards

ByNumber implemented for sort function to sort cards by number

func (ByNumber) Len

func (n ByNumber) Len() int

func (ByNumber) Less

func (n ByNumber) Less(i, j int) bool

func (ByNumber) Swap

func (n ByNumber) Swap(i, j int)

type Card

type Card struct {
	Suit  string `json:"suit"`
	Value string `json:"value"`
}

Card is a single element in the deck

type Cards

type Cards []Card

Cards is a list of Card objects. It can be used as a deck or a hand

func GetFiveBest

func GetFiveBest(cards Cards) (Cards, int)

GetFiveBest evaluates the hand and prints out what it is First return param: the 5 best cards Second return param: the ranking of the 5 best cards. Rankings can be found above

func (*Cards) Add

func (c *Cards) Add(cardsToAdd Cards)

Add adds cards to a Cards object. This is intended to be used for failed multistep checks (fullhouse, two pair)

func (Cards) Print

func (c Cards) Print(beforeStr, afterStr string)

Print prints cards

func (*Cards) Remove

func (c *Cards) Remove(cardsToRemove Cards)

Remove removes cards from a Cards object

func (*Cards) Sort

func (c *Cards) Sort()

Sort highest to lowest based on Value param

type Deal

type Deal struct {
	Hands       Hands        `json:"hands"`
	Board       Cards        `json:"board"`
	HandResults []HandResult `json:"results"`
}

Deal is the cards for the flop, turn, river and hands dealt to each player

func (*Deal) PrintBoard

func (d *Deal) PrintBoard()

PrintBoard prints the board for a game

func (*Deal) PrintBoardAndHands

func (d *Deal) PrintBoardAndHands()

PrintBoardAndHands prints the board and the hands

func (*Deal) PrintHands

func (d *Deal) PrintHands()

PrintHands prints the hands for a game

func (*Deal) PrintRanksAndBestFive

func (d *Deal) PrintRanksAndBestFive()

type Deck

type Deck struct {
	Cards         []Card
	NextCardIndex int
}

Deck is a Cards object and the next card to use

func GetDeck

func GetDeck() Deck

GetDeck returns a sorted deck of cards

func (*Deck) BurnAndFlip

func (d *Deck) BurnAndFlip(numCards int) Cards

BurnAndFlip takes in a parameter that is the number of cards to get It first skips a card then grabs the desired number of cards

func (*Deck) Deal

func (d *Deck) Deal(numHands, numCards int) Hands

Deal takes in the number of hands and the number of cards per hand and creates the hands from the deck, updating the next card as it goes

func (*Deck) DealHoldEm

func (d *Deck) DealHoldEm(numHands int) Hands

DealHoldEm deals 2 cards to the number of hands passed in eg: if 6 is passed in, it will return 6 hands of 2

func (*Deck) GetCard

func (d *Deck) GetCard() Card

GetCard gets the next card in a deck and updates the index of the deck object

func (*Deck) GetDeal

func (d *Deck) GetDeal(numPlayers int) Deal

GetDeal deals hands and returns a deal object

func (*Deck) GetFlop

func (d *Deck) GetFlop() Cards

GetFlop burns a card and returns the 3 after

func (*Deck) GetRiver

func (d *Deck) GetRiver() Cards

GetRiver burns a card and returns the card after

func (*Deck) GetTurn

func (d *Deck) GetTurn() Cards

GetTurn burns a card and returns the card after

func (Deck) PrintOrder

func (d Deck) PrintOrder()

PrintOrder prints the order of the deck

func (Deck) PrintRemainingCards

func (d Deck) PrintRemainingCards()

PrintRemainingCards prints the remaining cards in the deck

func (*Deck) Reset

func (d *Deck) Reset()

Reset resets the deck index to 0

func (*Deck) Shuffle

func (d *Deck) Shuffle()

Shuffle shuffles a deck of cards

type HandResult

type HandResult struct {
	Player           Player `json:"player"`
	RelativeHandRank int    `json:"rank"`
}

HandResult is the player number and the hand that they had This keeps track of the relative rank between players and the type of hand that they have

type Hands

type Hands []Cards

Hands is a list of Cards objects.

func (Hands) Print

func (h Hands) Print()

Print prints hands

type Player

type Player struct {
	Num      int    `json:"playerID"`
	BestFive Cards  `json:"bestFive"`
	HandName string `json:"handName"`
}

Player is a player that is part of a deal

type Players

type Players []Player

Players is a list of Player objects

func (Players) Print

func (p Players) Print()

Print prints players

Jump to

Keyboard shortcuts

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