bj

package
v0.0.0-...-2f4cb70 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SavedGameFile  = "bj.json"
	MinBet         = 5.0
	MaxBet         = 1000.0
	CardsPerDeck   = 52
	MaxPlayerHands = 7
	MinNumDecks    = 1
	MaxNumDecks    = 8

	// h.count
	HardCount = false
	SoftCount = true

	// h.Status
	Unknown = -2
	Lost    = -1
	Push    = 0
	Won     = 1
)

Variables

View Source
var CardFaces = [14][4]string{
	{"🂡", "🂱", "🃁", "🃑"},
	{"🂢", "🂲", "🃂", "🃒"},
	{"🂣", "🂳", "🃃", "🃓"},
	{"🂤", "🂴", "🃄", "🃔"},
	{"🂥", "🂵", "🃅", "🃕"},
	{"🂦", "🂶", "🃆", "🃖"},
	{"🂧", "🂷", "🃇", "🃗"},
	{"🂨", "🂸", "🃈", "🃘"},
	{"🂩", "🂹", "🃉", "🃙"},
	{"🂪", "🂺", "🃊", "🃚"},
	{"🂫", "🂻", "🃋", "🃛"},
	{"🂭", "🂽", "🃍", "🃝"},
	{"🂮", "🂾", "🃎", "🃞"},
	{"🂠", "", "", ""},
}
View Source
var ShuffleSpecs = []int{80, 81, 82, 84, 86, 89, 92, 95}
View Source
var Suits = [4]string{"Spades", "Hearts", "Diamonds", "Clubs"}

Functions

func GetChar

func GetChar() []byte

func New

func New()

Types

type Card

type Card struct {
	Value     int
	SuitValue int
}

func (*Card) IsAce

func (c *Card) IsAce() bool

func (*Card) IsTen

func (c *Card) IsTen() bool

type Game

type Game struct {
	Shoe
	DealerHand        Hand
	PlayerHands       []Hand
	NumberOfDecks     int
	CurrentPlayerHand int
	CurrentBet        float64
	Money             float64
}

func LoadGame

func LoadGame() (BJ *Game, err error)

func (*Game) AskPlayerInsurance

func (BJ *Game) AskPlayerInsurance()

func (*Game) Clear

func (BJ *Game) Clear()

func (*Game) DealNewHand

func (BJ *Game) DealNewHand()

func (*Game) DrawHands

func (BJ *Game) DrawHands()

func (*Game) DrawPlayerBetOptions

func (BJ *Game) DrawPlayerBetOptions()

func (*Game) GameOptions

func (BJ *Game) GameOptions()

func (*Game) GetNewBet

func (BJ *Game) GetNewBet()

func (*Game) GetNewDeckType

func (BJ *Game) GetNewDeckType()

func (*Game) GetNumDecks

func (BJ *Game) GetNumDecks()

func (*Game) MoreHandsToPlay

func (BJ *Game) MoreHandsToPlay() bool

func (*Game) NeedToPlayDealerHand

func (BJ *Game) NeedToPlayDealerHand() bool

func (*Game) PayHands

func (BJ *Game) PayHands()

func (*Game) PlayDealerHand

func (BJ *Game) PlayDealerHand()

func (*Game) PlayMoreHands

func (BJ *Game) PlayMoreHands()

func (*Game) String

func (BJ *Game) String() string

type Hand

type Hand struct {
	*Game
	IsDealer     bool
	HideDownCard bool
	Stood        bool
	Played       bool
	Paid         bool
	Status       int
	Bet          float64
	Cards        []Card
}

func (*Hand) CanDouble

func (h *Hand) CanDouble() bool

func (*Hand) CanHit

func (h *Hand) CanHit() bool

func (*Hand) CanSplit

func (h *Hand) CanSplit() bool

func (*Hand) CanStand

func (h *Hand) CanStand() bool

func (*Hand) DealCard

func (h *Hand) DealCard()

func (*Hand) GetValue

func (h *Hand) GetValue(softCount bool) int

func (*Hand) Hit

func (h *Hand) Hit()

func (*Hand) IsBlackjack

func (h *Hand) IsBlackjack() bool

func (*Hand) IsBusted

func (h *Hand) IsBusted() bool

func (*Hand) IsDone

func (h *Hand) IsDone() bool

func (*Hand) Process

func (h *Hand) Process()

func (*Hand) Stand

func (h *Hand) Stand()

type SavedGame

type SavedGame struct {
	NumberOfDecks int
	CurrentBet    float64
	Money         float64
}

type Shoe

type Shoe struct {
	*Game
	Top   int
	Cards []Card
}

func NewShoe

func NewShoe(BJ *Game) Shoe

func (*Shoe) CheckNeedToShuffle

func (s *Shoe) CheckNeedToShuffle() bool

func (*Shoe) GetNextCard

func (s *Shoe) GetNextCard() Card

func (*Shoe) NewAces

func (s *Shoe) NewAces()

func (*Shoe) NewAcesJacks

func (s *Shoe) NewAcesJacks()

func (*Shoe) NewEights

func (s *Shoe) NewEights()

func (*Shoe) NewJacks

func (s *Shoe) NewJacks()

func (*Shoe) NewRegular

func (s *Shoe) NewRegular()

func (*Shoe) NewSevens

func (s *Shoe) NewSevens()

func (*Shoe) Shuffle

func (s *Shoe) Shuffle()

Jump to

Keyboard shortcuts

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