camel

package
v0.0.0-...-81698c8 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

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

type Game

type Game struct {
	Hands Hands
	// contains filtered or unexported fields
}

func NewGame

func NewGame(opts ...GameOption) *Game

func (*Game) Parse

func (g *Game) Parse(r io.Reader) error

func (Game) Rank

func (g Game) Rank() Hands

Rank sorts the hands in place, ordering by type strength, lowest rank first.

func (Game) TotalWinnings

func (g Game) TotalWinnings() int

TotalWinnings ranks the hands by type, then calculates the winnings based on the hand's bid and rank.

type GameOption

type GameOption func(*Game)

func WithWildcard

func WithWildcard(card Label) GameOption

type Hand

type Hand struct {
	Cards [5]Card
	Bid   int
	// contains filtered or unexported fields
}

func (*Hand) ParseLabels

func (h *Hand) ParseLabels(raw string)

ParseLabels takes a hand as a string, e.g. "K234J" and populates the hand struct.

func (Hand) String

func (h Hand) String() string

func (Hand) Type

func (h Hand) Type(useWildcard bool) HandType

Type finds the number of sets of matching cards and returns the associated HandType.

type HandType

type HandType int
const (
	HighCard     HandType = iota // HighCard is where all cards' labels are distinct: 23456
	OnePair                      // OnePair is where two cards share one label, and the other three cards have a different label from the pair and each other: A23A4
	TwoPair                      // TwoPair is where two cards share one label, two other cards share a second label, and the remaining card has a third label: 23432
	ThreeOfAKind                 // ThreeOfAKind is where three cards have the same label, and the remaining two cards are each different from any other card in the hand: TTT98
	FullHouse                    // A full house is where three cards have the same label, and the remaining two cards share a different label: 23332
	FourOfAKind                  // FourOfAKind is where four cards have the same label and one card has a different label: AA8AA
	FiveOfAKind                  // FiveOfAKind is where all five cards have the same label: AAAAA.
)

func (HandType) String

func (t HandType) String() string

type Hands

type Hands []Hand

func ParseHands

func ParseHands(r io.Reader, opts ...handOption) (Hands, error)

type Label

type Label string
const (
	LabelA Label = "A"
	LabelK Label = "K"
	LabelQ Label = "Q"
	LabelJ Label = "J"
	LabelT Label = "T"
	Label9 Label = "9"
	Label8 Label = "8"
	Label7 Label = "7"
	Label6 Label = "6"
	Label5 Label = "5"
	Label4 Label = "4"
	Label3 Label = "3"
	Label2 Label = "2"
)

Jump to

Keyboard shortcuts

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