poker

package
v0.0.0-...-adb926b Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CardRankNames = []string{
	"One",
	"Two",
	"Three",
	"Four",
	"Five",
	"Six",
	"Seven",
	"Eight",
	"Nine",
	"Ten",
	"Jack",
	"Queen",
	"King",
	"Ace",
}

CardRankNames is a list of suit names

View Source
var CardRanks = []CardRank{
	One,
	Two,
	Three,
	Four,
	Five,
	Six,
	Seven,
	Eight,
	Nine,
	Ten,
	Jack,
	Queen,
	King,
	Ace,
}

CardRanks is a list of available suits

View Source
var CardSuitNames = []string{
	"Heart",
	"Diamond",
	"Club",
	"Spade",
}

CardSuitNames is a list of suit names

View Source
var CardSuits = []CardSuit{
	Heart,
	Diamond,
	Club,
	Spade,
}

CardSuits is a list of available suits

View Source
var GameTypeNames = []string{
	"Cash",
	"Tournament",
}

LimitNames is a list of limit names

View Source
var GameTypes = []GameType{
	Cash,
	Tournament,
}

GameTypes is a list of all available game types

View Source
var LimitNames = []string{
	"No limit",
	"Pot limit",
	"Fixed limit",
}

LimitNames is a list of limit names

Limits is a list of all available limits

Functions

This section is empty.

Types

type Blind

type Blind float64

Blind represents both blinds (since they are directly related)

func (Blind) Big

func (v Blind) Big() float64

Big gets big blind

func (Blind) Small

func (v Blind) Small() float64

Small gets small blind

func (Blind) String

func (v Blind) String() string

type Blinds

type Blinds struct {
	Small float64
	Big   float64
}

Blinds represents both small and big blind

type Card

type Card struct {
	CardRank CardRank
	CardSuit CardSuit
}

Card represents a playing card in a poker hand

type CardRank

type CardRank int

CardRank represents the card rank such as (one, two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace, joker)

const (
	UnknownCardRank CardRank = iota
	Ace
	King
	Queen
	Jack
	Ten
	Nine
	Eight
	Seven
	Six
	Five
	Four
	Three
	Two
	One
)

func (CardRank) String

func (v CardRank) String() string

type CardSuit

type CardSuit int

CardSuit represents the card suit such as heart, dimaond, club and spade

const (
	UnknownCardSuit CardSuit = iota
	Heart
	Diamond
	Club
	Spade
)

func (CardSuit) String

func (v CardSuit) String() string

type Cards

type Cards []Card

Cards can represent a hand or a deck

func (Cards) Extract

func (v Cards) Extract(index int) (Cards, Card, error)

Extract extracts one card out of the card collection

type Deck

type Deck []Card

Deck represents a deck of cards with basic shuffle and pull functionality

func (Deck) Draw

func (d Deck) Draw(amount int) (Deck, []Card)

Draw draws amount of cards out of deck from top and returns the altered deck + drawed

func (*Deck) Reset

func (d *Deck) Reset(randomizer Randomizer, suits []CardSuit, ranks []CardRank)

Reset resets deck to a shuffled state with each of every rank and suit

type Event

type Event struct {
	TableEvent *TableEvent
}

type Game

type Game struct {
	Type  GameType
	Rules Rules
	Limit Limit

	// Break Related
	NextBreak     time.Time
	BreakInterval time.Duration

	// Mandatory Structure Related
	NextLevel          time.Time
	CurrentLevel       uint
	LevelInterval      time.Duration
	MandatoryStructure []MandatoryStructure
}

Game represents a poker game (also tournaments)

type GameType

type GameType int

GameType represents game type

const (
	UnknownType GameType = iota
	Cash
	Tournament
)

func (GameType) String

func (v GameType) String() string

type Limit

type Limit int

Limit represents betting limit

const (
	NoLimit Limit = iota
	PotLimit
	FixedLimit
)

func (Limit) String

func (v Limit) String() string

type MandatoryStructure

type MandatoryStructure struct {
	Blind Blind
	Ante  float64
}

MandatoryStructure ...

type Player

type Player struct {
	AccountID  int
	Chips      float64
	Nickname   string
	Avatar     string
	Connected  bool
	Inactive   bool
	LastAction time.Time
}

Player represents a player at a table

type PlayerStatus

type PlayerStatus int

PlayerStatus represents the players current table status

const (
	EnteringNextHand     PlayerStatus = -3
	EnteringNextBigBlind PlayerStatus = -2
	SittingOut           PlayerStatus = -1
	Empty                PlayerStatus = iota
	BuyIn
	Playing
	Folded
)

type Randomizer

type Randomizer interface {
	// Shuffle pseudo-randomizes the order of elements using the default Source.
	// n is the number of elements. Shuffle panics if n < 0.
	// swap swaps the elements with indexes i and j.
	Shuffle(n int, swap func(i, j int))
}

Randomizer is used by a deck to randomize outcomes of shuffles

type Rules

type Rules interface {
	// Stage perfoms the provided stage, adjusts accordingly and then returns the changed table state and the next stage
	Stage(table Table, stage Stage) (outcome Table, nextStage Stage)
	// Win checks if slot1 beats slot2 with provided community cards
	// returns 0 if it's a tie, 1 if slot1 wins, 2 if slot2 wins
	Win(player1 []Card, player2 []Card, community []Card) int
}

Rules implements the funcs used by Game to determine outcome

type Slot

type Slot struct {
	Player          Player
	Cards           []Card
	Status          PlayerStatus
	SittingOutSince time.Time
}

Slot represents a table slot

type Stage

type Stage int

Stage represents the stage a round is in

const (
	ThrowTwoCard Stage = -2
	ThrowOneCard Stage = -1
	Deal         Stage = iota
	PreFlop
	Flop
	Turn
	River
	End
)

type Table

type Table struct {
	Slots          []Slot
	Deck           Deck
	CommunityCards []Card
	DiscardedCards []Card
}

Table represents a poker table

func NewTable

func NewTable(capacity int) Table

NewTable creates a table with provided capacity

type TableEvent

type TableEvent struct {
	RoomID int
	Text   string
}

TableEvent describes a state change on a table

type TableEventType

type TableEventType int

TableEventType type of table event

const (
	UnknownTableEventType TableEventType = iota
	DeniedEntrance
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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