poker

package module
v0.0.0-...-e417ecf Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2017 License: GPL-3.0 Imports: 6 Imported by: 2

README

poker-common

Commonalities between poker modules

Documentation

Index

Constants

View Source
const (
	// Texas Hold'em No Limit game
	TexasHoldEmNoLimit game = iota

	// Unknown game
	Unknown
)

List of games

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {

	// String returns string representation of the action.
	String() string

	// Amount returns the associated amount (not relevant to all action types).
	Amount() Amount
}

Action is the interface to a player action.

func NewBetAction

func NewBetAction(amount Amount) Action

NewBetAction creates a new bet action.

func NewCallAction

func NewCallAction(amount Amount) Action

NewCallAction creates a new call action.

func NewCheckAction

func NewCheckAction() Action

NewCheckAction creates a new check action.

func NewFoldAction

func NewFoldAction() Action

NewFoldAction creates a new fold action.

func NewRaiseAction

func NewRaiseAction(amount Amount) Action

NewRaiseAction creates a new raise action.

type Amount

type Amount int

Amount represents an amount of US cents.

func NewAmount

func NewAmount(amount float64) Amount

NewAmount creates an amount from a float.

func ParseAmount

func ParseAmount(amount string) (Amount, error)

ParseAmount parses an amount from a string. The string may contain '$' and 'USD'.

func (Amount) MarshalJSON

func (a Amount) MarshalJSON() ([]byte, error)

MarshalJSON marshals the string representation of the amount.

func (Amount) String

func (a Amount) String() string

String returns a string representing the amount in the form '$2.32'.

func (Amount) UnmarshalJSON

func (a Amount) UnmarshalJSON(data []byte) error

UnmarshalJSON parses an amount from JSON.

type Date

type Date time.Time

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (Date) String

func (d Date) String() string

type Game

type Game interface {
	Game() game
	String() string
}

Game is the interface to a value which describes a game. The Game interface exists to disallow external code to create new types of games.

func ParseGame

func ParseGame(gameStr string) (Game, error)

ParseGame parses a game mode.

type Hand

type Hand struct {
	Client     string
	Table      Table
	HandID     int
	Date       Date
	Button     PlayerPosition
	SmallBlind PlayerPosition
	BigBlind   PlayerPosition
	ThisPlayer *PlayerCards
	Players    []Player
	Rounds     []Round
	Result     *Result
}

func (*Hand) String

func (h *Hand) String() string

type Player

type Player struct {

	// Name is the player's name.
	Name string

	// Stack is the player's stack at hand start.
	Stack Amount
}

Player represents a poker player.

func (*Player) UnmarshalJSON

func (p *Player) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a player from JSON.

type PlayerAction

type PlayerAction struct {

	// Position is the player's position.
	Position PlayerPosition

	// Action is the player's action.
	Action Action
}

PlayerAction is a player's action.

func (*PlayerAction) UnmarshalJSON

func (p *PlayerAction) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a player action from JSON.

type PlayerCards

type PlayerCards struct {

	// Position is the player's position.
	Position PlayerPosition

	// Cards are the player's cards.
	Cards []card.Card
}

PlayerCards is a player's cards.

func (*PlayerCards) UnmarshalJSON

func (p *PlayerCards) UnmarshalJSON(b []byte) error

UnmarshalJSON parses player cards from JSON.

type PlayerPosition

type PlayerPosition int

PlayerPosition is a position of a player. PlayerPositions are 1-indexed, and a value of 0 means 'no player'.

func NextPlayerPosition

func NextPlayerPosition(pos PlayerPosition, tableSize int) PlayerPosition

NextPlayerPosition returns the next player position at the table.

func PreviousPlayerPosition

func PreviousPlayerPosition(pos PlayerPosition, tableSize int) PlayerPosition

PreviousPlayerPosition returns the previous player position at the table.

func (PlayerPosition) Player

func (p PlayerPosition) Player(h *Hand) *Player

Player returns the player given his position. h is the hand in question.

type Result

type Result struct {
	Winner    PlayerPosition
	Pot       Amount
	ShowDowns []PlayerCards
}

type Round

type Round struct {
	Cards   []card.Card
	Pot     Amount
	Actions []PlayerAction
}

type Stakes

type Stakes struct {

	// SmallBlind is the size of the small blind.
	SmallBlind Amount

	// BigBlind is the size of the big blind.
	BigBlind Amount
}

Stakes represents table stakes.

func ParseStakes

func ParseStakes(stakes string) (Stakes, error)

ParseStakes parses a string to a stakes object. The string must be in a format similar to '$0.01/$0.02 USD'.

func (Stakes) MarshalJSON

func (s Stakes) MarshalJSON() ([]byte, error)

MarshalJSON marshals the string representation of stakes.

func (Stakes) String

func (s Stakes) String() string

String returns a string representation of the stakes in the form '$0.01/$0.02 USD'.

func (*Stakes) UnmarshalJSON

func (s *Stakes) UnmarshalJSON(b []byte) error

UnmarshalJSON parses stakes from JSON.

type Table

type Table struct {

	// Name of the table.
	Name string

	// Stakes of the table.
	Stakes Stakes

	// Size of the table (number of seats).
	Size int

	// Game is the game type.
	Game Game
}

Table represents a poker table.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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