game

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuitClubs    = "clubs"
	SuitDiamonds = "diamonds"
	SuitHearts   = "hearts"
	SuitSpades   = "spades"
)
View Source
const (
	RankAce   = "a"
	RankKing  = "k"
	RankQueen = "q"
	RankJack  = "j"
	Rank10    = "10"
	Rank9     = "9"
	Rank8     = "8"
	Rank7     = "7"
	Rank6     = "6"
	Rank5     = "5"
	Rank4     = "4"
	Rank3     = "3"
	Rank2     = "2"
)
View Source
const (
	StateNewGame uint8 = iota
	StatePlayerTurn
	StateDealerTurn
	StateGameOver
)
View Source
const (
	ResultPending uint8 = iota
	ResultPlayerWin
	ResultDealerWin
	ResultPush
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	Suit string
	Rank string
}

func NewCard

func NewCard(suit, rank string) Card

func (Card) Value

func (c Card) Value() int

type Deck

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

func NewDeck

func NewDeck() *Deck

func (*Deck) Draw

func (d *Deck) Draw() Card

func (*Deck) Shuffle

func (d *Deck) Shuffle()

type Flow

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

func NewFlow

func NewFlow() *Flow

func (*Flow) Deal

func (f *Flow) Deal()

func (*Flow) EndGame

func (f *Flow) EndGame(result uint8)

func (*Flow) IsGameOver

func (f *Flow) IsGameOver() bool

func (*Flow) Reset

func (f *Flow) Reset()

func (*Flow) Result

func (f *Flow) Result() uint8

func (*Flow) Stand

func (f *Flow) Stand()

func (*Flow) State

func (f *Flow) State() uint8

type Game

type Game struct {
	Flow *Flow

	PlayerHand *Hand
	DealerHand *Hand
	// contains filtered or unexported fields
}

func NewGame

func NewGame() *Game

func (*Game) Deal

func (g *Game) Deal()

func (*Game) DealerPlay

func (g *Game) DealerPlay()

func (*Game) DetermineWinner

func (g *Game) DetermineWinner() uint8

func (*Game) Hit

func (g *Game) Hit()

func (*Game) Stand

func (g *Game) Stand()

type Hand

type Hand struct {
	Cards []Card
}

func NewHand

func NewHand() *Hand

func (*Hand) AddCard

func (h *Hand) AddCard(c Card)

func (*Hand) Clear

func (h *Hand) Clear()

func (*Hand) IsBlackjack

func (h *Hand) IsBlackjack() bool

func (*Hand) IsBusted

func (h *Hand) IsBusted() bool

func (*Hand) Value

func (h *Hand) Value() int

Jump to

Keyboard shortcuts

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