events

package
v0.0.0-...-d26b62e Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ACTION_PROCESSED = "ACTION_PROCESSED"
View Source
const ALL_IN = 5

ALL_IN action bets the entire wallet of the user in this round

View Source
const BET = 2

BET describes the action of a player betting the same amount as the highest bet and therefore go along or calling the hand

View Source
const CHECK = 4

CHECK action pushes the action requirement to the next player

View Source
const DEALER_SET = "DEALER_SET"
View Source
const FLOP = "FLOP"
View Source
const FOLD = 1

FOLD describes the action of a player quiting this hand

View Source
const GAME_END = "GAME_END"
View Source
const GAME_START = "GAME_START"
View Source
const HOLE_CARDS = "HOLE_CARDS"
View Source
const JOIN = "JOIN"
View Source
const JOIN_SUCCESS = "JOIN_SUCCESS"
View Source
const LOBBY_INFO = "LOBBY_INFO"
View Source
const LOBBY_PAUSE = "LOBBY_PAUSE"
View Source
const PLAYER_ACTION = "PLAYER_ACTION"
View Source
const PLAYER_JOIN = "PLAYER_JOIN"
View Source
const PLAYER_LEAVE = "PLAYER_LEAVE"
View Source
const RAISE = 3

RAISE raises sets the highest bet a certain amount

View Source
const REQUIRED_EVENT_NAME_MISSING = "The event received does not match the required event name"
View Source
const RIVER = "RIVER"
View Source
const TURN = "TURN"
View Source
const WAIT_FOR_PLAYER_ACTION = "WAIT_FOR_PLAYER_ACTION"

Variables

This section is empty.

Functions

func NewActionProcessedEvent

func NewActionProcessedEvent(player *models.PublicPlayer, action, position int, amount, totalAmount, wallet, pot *money.Money) *models.Event

func NewDealerSetEvent

func NewDealerSetEvent(player *models.PublicPlayer, index int) *models.Event

func NewFlopEvent

func NewFlopEvent(cards [5]models.Card) *models.Event

func NewGameEndEvent

func NewGameEndEvent(winners []models.PublicPlayer, shares *money.Money) *models.Event

func NewGameStartEvent

func NewGameStartEvent(publicPlayers []models.PublicPlayer, position int, pot *money.Money) *models.Event

func NewHoleCardsEvent

func NewHoleCardsEvent(cards [2]models.Card) *models.Event

func NewJoinSuccessEvent

func NewJoinSuccessEvent(players []models.PublicPlayer, position int, buyIn *money.Money, gameStarted bool) *models.Event

func NewLobbyInfoEvent

func NewLobbyInfoEvent(lobbyId string, players, minToStart, maxBuyIn, minBuyIn, blind, gameStartTimeout int, gameStarted bool) *models.Event

NewLobbyInfoEvent

func NewLobbyPauseEvent

func NewLobbyPauseEvent(players []models.PublicPlayer, playerCount int) *models.Event

func NewPlayerJoinEvent

func NewPlayerJoinEvent(player *models.PublicPlayer, index, playerCount int, gameStarted bool) *models.Event

NewPlayerJoinEvent creates a player join event for all other players to receive. The joining player receives a join success message

func NewPlayerLeavesEvent

func NewPlayerLeavesEvent(player *models.PublicPlayer, i, playerCount int, gameStarted bool) *models.Event

func NewRiverEvent

func NewRiverEvent(cards [5]models.Card) *models.Event

func NewTurnEvent

func NewTurnEvent(cards [5]models.Card) *models.Event

func NewWaitForActionEvent

func NewWaitForActionEvent(player *models.PublicPlayer, position int, possibleActions byte) *models.Event

NewWaitForAction is an event that the server is waiting for an action from a given player. The possible actions range from 0001 = Fold | 0010=Bet | 0100=Raise | 1000=Check to 1111=All

func ValidateEventName

func ValidateEventName(expected, live string) bool

ValidateEventName validates if the live event name equals the required with case insensetivity

Types

type Action

type Action struct {
	Action  int          `json:"action" mapstructure:"action"`
	Payload *money.Money `json:"payload" mapstructure:"payload"`
}

Action describes a action a player can make one a normal hand stage

func ToAction

func ToAction(raw *models.Event) (*Action, error)

type ActionDTO

type ActionDTO struct {
	Action  int `json:"action" mapstructure:"action"`
	Payload int `json:"payload" mapstructure:"payload"`
}

Action describes a action a player can make one a normal hand stage

func ToActionDTO

func ToActionDTO(raw *models.Event) (*ActionDTO, error)

type ActionProcessedEvent

type ActionProcessedEvent struct {
	Player         *models.PublicPlayer `json:"player" mapstructure:"player"`
	Pot            string               `json:"pot" mapstructure:"pot"`
	PotNum         float64              `json:"potNum" mapstructure:"potNum"`
	Wallet         string               `json:"wallet" mapstructure:"wallet"`
	WalletNum      float64              `json:"walletNum" mapstructure:"wallet"`
	TotalAmount    string               `json:"totalAmount" mapstructure:"totalAmount"`
	TotalAmountNum float64              `json:"totalAmountNum" mapstructure:"totalAmountNum"`
	Amount         string               `json:"amount" mapstructure:"amount"`
	AmountNum      float64              `json:"amountNum" mapstructure:"amountNum"`
	Action         int                  `json:"action" mapstructure:"action"`
	Position       int                  `json:"position" mapstructure:"position"`
}

type BoardEvent

type BoardEvent struct {
	Cards []models.Card `json:"cards" mapstructure:"cards"`
}

type DealerSetEvent

type DealerSetEvent struct {
	Player *models.PublicPlayer `json:"player"`
	Index  int                  `json:"index"`
}

type GameEndEvent

type GameEndEvent struct {
	Winners   []models.PublicPlayer `json:"winners"`
	Shares    string                `json:"shares"`
	SharesNum float64               `json:"sharesNum"`
}

type GameStartEvent

type GameStartEvent struct {
	Players  []models.PublicPlayer `json:"players"`
	Pot      string                `json:"pot"`
	PotNum   float64               `json:"potNum"`
	Position int                   `json:"position"`
}

type HoleCardsEvent

type HoleCardsEvent struct {
	Cards [2]models.Card `json:"cards"`
}

type JoinEvent

type JoinEvent struct {
	Token string `json:"token"`
}

func ToJoinEvent

func ToJoinEvent(raw *models.Event) (*JoinEvent, error)

type JoinSuccess

type JoinSuccess struct {
	Players     []models.PublicPlayer `json:"players"`
	BuyIn       string                `json:"buyin"`
	BuyInNum    float64               `json:"buyInNum"`
	Position    int                   `json:"position"`
	GameStarted bool                  `json:"gameStarted"`
	Reconnect   bool                  `json:"reconnect"`
}

type LobbyInfo

type LobbyInfo struct {
	LobbyID          string `json:"lobbyId"`
	MaxBuyIn         int    `json:"maxBuyIn"`
	MinBuyIn         int    `json:"minBuyIn"`
	Blind            int    `json:"blind"`
	MinToStart       int    `json:"minPlayersToStart"`
	PlayerCount      int    `json:"playerCount"`
	GameStartTimeout int    `json:"gameStartTimeout"`
	GameStarted      bool   `json:"gameStarted"`
}

type LobbyPause

type LobbyPause struct {
	Players     []models.PublicPlayer `json:"players"`
	PlayerCount int                   `json:"playerCount"`
}

type PlayerJoinEvent

type PlayerJoinEvent struct {
	Player      *models.PublicPlayer `json:"player"`
	Index       int                  `json:"index"`
	PlayerCount int                  `json:"playerCount"`
	GameStarted bool                 `json:"gameStarted"`
}

NewPlayerJoinEvent is the event for all other players to receive when another player joins. The joining player receives a join success message

type PlayerLeavesEvent

type PlayerLeavesEvent struct {
	Player      *models.PublicPlayer `json:"player"`
	Index       int                  `json:"index"`
	PlayerCount int                  `json:"playerCount"`
	GameStarted bool                 `json:"gameStarted"`
}

PlayerLeavesEvent messages that a player left

type WaitForActionEvent

type WaitForActionEvent struct {
	Player          *models.PublicPlayer `json:"player"`
	Position        int                  `json:"position" mapstructure:"position"`
	PossibleActions byte                 `json:"possibleActions" mapstructure:"possibleActions"`
}

WaitForActionEvent encodes all possible actions the user can perform.

Jump to

Keyboard shortcuts

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