pokermodel

package module
v0.0.0-...-20d6285 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 5

README

pokermodel

pokermodel is poker game models written in golang.

Documentation

Index

Constants

View Source
const (
	// CompetitionStateStatus
	CompetitionStateStatus_Uncreated     CompetitionStateStatus = "uncreated"     // 賽事尚未建立
	CompetitionStateStatus_Unregistering CompetitionStateStatus = "unregistering" // 賽事已建立 (但不可報名)
	CompetitionStateStatus_Registering   CompetitionStateStatus = "registering"   // 賽事已建立 (可報名參賽)
	CompetitionStateStatus_DelayedBuyin  CompetitionStateStatus = "delayed_buyin" // 賽事已建立 (延遲買入)
	CompetitionStateStatus_StoppedBuyin  CompetitionStateStatus = "stopped_buyin" // 賽事已建立 (停止買入)
	CompetitionStateStatus_End           CompetitionStateStatus = "end"           // 賽事已結束
	CompetitionStateStatus_Restoring     CompetitionStateStatus = "restoring"     // 賽事資料轉移中 (Graceful Shutdown Use)

	// CompetitionPlayerStatus
	CompetitionPlayerStatus_WaitingDistributeTables CompetitionPlayerStatus = "waiting_distribute_tables" // 等待拆併桌
	CompetitionPlayerStatus_Playing                 CompetitionPlayerStatus = "playing"                   // 比賽中
	CompetitionPlayerStatus_Knockout                CompetitionPlayerStatus = "knockout"                  // 已淘汰

	// CompetitionMode
	CompetitionMode_CT   = "ct"   // 倒數錦標賽
	CompetitionMode_MTT  = "mtt"  // 大型錦標賽
	CompetitionMode_Cash = "cash" // 現金桌

	// CompetitionRule
	CompetitionRule_Default   = "default"    // 常牌
	CompetitionRule_ShortDeck = "short_deck" // 短牌
	CompetitionRule_Omaha     = "omaha"      // 奧瑪哈
)
View Source
const (
	UnsetIndex = -1
)

Variables

This section is empty.

Functions

func JSONStringfy

func JSONStringfy(data interface{}) (*string, error)

Types

type AddonSetting

type AddonSetting struct {
	IsBreakOnly bool    `json:"is_break_only"` // 是否中場休息限定
	RedeemChips []int64 `json:"redeem_chips"`  // 可兌換籌碼數
	MaxTimes    int     `json:"max_times"`     // 最大次數
}

type Blind

type Blind struct {
	ID               string       `json:"id"`                 // ID
	Name             string       `json:"name"`               // 名稱
	FinalBuyInLevel  int          `json:"final_buy_in_level"` // 最後買入盲注等級
	DealerBlindTimes int          `json:"delear_blind_times"` // Dealer 位置要收取的前注倍數 (短牌用)
	Levels           []BlindLevel `json:"levels"`             // 級別資訊列表
}

type BlindLevel

type BlindLevel struct {
	Level        int   `json:"level"`         // 盲注等級(-1 表示中場休息)
	SBChips      int64 `json:"sb_chips"`      // 小盲籌碼量
	BBChips      int64 `json:"bb_chips"`      // 大盲籌碼量
	AnteChips    int64 `json:"ante_chips"`    // 前注籌碼量
	DurationMins int   `json:"duration_mins"` // 等級持續時間
}

type BuyInSetting

type BuyInSetting struct {
	IsFree     bool `json:"is_free"`     // 是否免費參賽
	MinTickets int  `json:"min_tickets"` // 最小票數
	MaxTickets int  `json:"max_tickets"` // 最大票數
}

type Competition

type Competition struct {
	ID       string            `json:"id"`        // 賽事 Unique ID
	Meta     CompetitionMeta   `json:"meta"`      // 賽事固定資料
	State    *CompetitionState `json:"state"`     // 賽事動態資料
	UpdateAt int64             `json:"update_at"` // 更新時間
}

func (Competition) GetJSON

func (competition Competition) GetJSON() (*string, error)

Competition Getters

type CompetitionMeta

type CompetitionMeta struct {
	Blind                Blind           `json:"blind"`                   // 盲注資訊
	Ticket               Ticket          `json:"ticket"`                  // 票券資訊
	Scene                string          `json:"scene"`                   // 場景
	MaxDurationMins      int             `json:"max_duration_mins"`       // 比賽時間總長 (分鐘)
	MinPlayerCount       int             `json:"min_player_count"`        // 最小參賽人數
	MaxPlayerCount       int             `json:"max_player_count"`        // 最大參賽人數
	Rule                 CompetitionRule `json:"rule"`                    // 德州撲克規則, 常牌(default), 短牌(short_deck), 奧瑪哈(omaha)
	Mode                 CompetitionMode `json:"mode"`                    // 賽事模式 (CT, MTT, Cash)
	BuyInSetting         BuyInSetting    `json:"buy_in_setting"`          // BuyIn 設定
	ReBuySetting         ReBuySetting    `json:"re_buy_setting"`          // ReBuy 設定
	AddonSetting         AddonSetting    `json:"addon_setting"`           // Addon 設定
	ActionTimeSecs       int             `json:"action_time_secs"`        // 思考時間 (秒數)
	TableMaxSeatCount    int             `json:"table_max_seat_count"`    // 每桌人數上限
	TableMinPlayingCount int             `json:"table_min_playing_count"` // 每桌最小開打數
	MinChipsUnit         int64           `json:"min_chips_unit"`          // 最小單位籌碼量
}

type CompetitionMode

type CompetitionMode string

type CompetitionPlayer

type CompetitionPlayer struct {
	PlayerID string `json:"player_id"` // 玩家 ID
	TableID  string `json:"table_id"`  // 桌次 ID
	JoinAt   int64  `json:"join_at"`   // 加入時間

	// current info
	Status     CompetitionPlayerStatus `json:"status"`       // 參與玩家狀態
	Rank       int                     `json:"rank"`         // 排名
	Chips      int64                   `json:"chips"`        // 當前籌碼
	ReBuyTimes int                     `json:"re_buy_times"` // 補碼次數
	AddonTimes int                     `json:"addon_times"`  // 增購次數

	// statistics info
	// best
	BestWinningPotChips int64    `json:"best_winning_pot_chips"` // 贏得最大底池籌碼數
	BestWinningCombo    []string `json:"best_winning_combo"`     // 身為贏家時最大的牌型組合

	// accumulated info
	// competition/table
	TotalRedeemChips int64 `json:"total_redeem_chips"` // 累積兌換籌碼
	TotalGameCounts  int64 `json:"total_game_counts"`  // 總共玩幾手牌

	// game: round & actions
	TotalWalks            int64 `json:"total_walks"`              // Preflop 除了大盲以外的人全部 Fold,而贏得籌碼的次數
	TotalVPIPTimes        int   `json:"total_vpip_times"`         // 入池總次數
	TotalFoldTimes        int   `json:"total_fold_times"`         // 棄牌總次數
	TotalPreflopFoldTimes int   `json:"total_preflop_fold_times"` // Preflop 棄牌總次數
	TotalFlopFoldTimes    int   `json:"total_flop_fold_times"`    // Flop 棄牌總次數
	TotalTurnFoldTimes    int   `json:"total_turn_fold_times"`    // Turn 棄牌總次數
	TotalRiverFoldTimes   int   `json:"total_river_fold_times"`   // River 棄牌總次數
	TotalActionTimes      int   `json:"total_action_times"`       // 下注動作總次數
	TotalRaiseTimes       int   `json:"total_raise_times"`        // 加注/入池總次數(AllIn&Raise、Raise、Bet)
	TotalCallTimes        int   `json:"total_call_times"`         // 跟注總次數
	TotalCheckTimes       int   `json:"total_check_times"`        // 過牌總次數
}

type CompetitionPlayerStatus

type CompetitionPlayerStatus string

type CompetitionRank

type CompetitionRank struct {
	PlayerID   string `json:"player_id"`   // 玩家 ID
	FinalChips int64  `json:"final_chips"` // 玩家最後籌碼數
}

type CompetitionRule

type CompetitionRule string

type CompetitionState

type CompetitionState struct {
	OpenGameAt    int64                  `json:"open_game_at"`    // 比賽開始時間 (可報名、尚未開打)
	DisableGameAt int64                  `json:"disable_game_at"` // 比賽未開打前,賽局可見時間
	StartGameAt   int64                  `json:"start_game_at"`   // 比賽開打時間 (可報名、開打)
	EndGameAt     int64                  `json:"end_game_at"`     // 比賽結束時間
	Players       []*CompetitionPlayer   `json:"players"`         // 參與過比賽玩家陣列
	Status        CompetitionStateStatus `json:"status"`          // 賽事狀態
	Tables        []*Table               `json:"tables"`          // 多桌
	Rankings      []*CompetitionRank     `json:"rankings"`        // 玩家排名 (陣列 Index 即是排名 rank - 1, ex: index 0 -> 第一名, index 1 -> 第二名...)
}

type CompetitionStateStatus

type CompetitionStateStatus string

type ReBuySetting

type ReBuySetting struct {
	MinTicket        int `json:"min_ticket"`          // 最小票數
	MaxTicket        int `json:"max_ticket"`          // 最大票數
	MaxTimes         int `json:"max_times"`           // 最大次數
	WaitingTimeInSec int `json:"waiting_time_in_sec"` // 玩家可補碼時間
}

type Table

type Table struct {
	ID       string      `json:"id"`
	Meta     TableMeta   `json:"meta"`
	State    *TableState `json:"state"`
	UpdateAt int64       `json:"update_at"`
}

func (Table) AlivePlayers

func (t Table) AlivePlayers() []*TablePlayerState

func (Table) EndGameAt

func (t Table) EndGameAt() int64

func (Table) GetJSON

func (table Table) GetJSON() (*string, error)

func (Table) ModeRule

func (table Table) ModeRule() string

Table Getters

func (Table) ParticipatedPlayers

func (table Table) ParticipatedPlayers() []*TablePlayerState

func (*Table) Reset

func (table *Table) Reset()

func (*Table) Update

func (table *Table) Update()

Setters

type TableBlindLevelState

type TableBlindLevelState struct {
	BlindLevel BlindLevel `json:"blind_level"`  // 盲注等級資訊
	LevelEndAt int64      `json:"level_end_at"` // 等級結束時間
}

type TableBlindState

type TableBlindState struct {
	FinalBuyInLevelIndex int                     `json:"final_buy_in_level_idx"` // 最後買入盲注等級索引值
	InitialLevel         int                     `json:"initial_level"`          // 起始盲注級別
	CurrentLevelIndex    int                     `json:"current_level_index"`    // 現在盲注等級級別索引值
	LevelStates          []*TableBlindLevelState `json:"level_states"`           // 級別資訊列表狀態
}

func (TableBlindState) CurrentBlindLevel

func (bs TableBlindState) CurrentBlindLevel() TableBlindLevelState

func (TableBlindState) IsBreaking

func (bs TableBlindState) IsBreaking() bool

func (TableBlindState) IsFinalBuyInLevel

func (bs TableBlindState) IsFinalBuyInLevel() bool

TableBlindState Getters

func (*TableBlindState) Update

func (bs *TableBlindState) Update()

TableBlindState Setters

type TableMeta

type TableMeta struct {
	ShortID         string          `json:"short_id"`         // Table ID 簡短版 (大小寫英文或數字組成6位數)
	Code            string          `json:"code"`             // 桌次編號
	Name            string          `json:"name"`             // 桌次名稱
	InvitationCode  string          `json:"invitation_code"`  // 桌次邀請碼
	CompetitionMeta CompetitionMeta `json:"competition_meta"` // 賽事固定資料
}

type TablePlayerState

type TablePlayerState struct {
	PlayerID          string   `json:"player_id"`            // 玩家 ID
	SeatIndex         int      `json:"seat_index"`           // 座位編號 0 ~ 8
	Positions         []string `json:"positions"`            // 場上位置
	IsParticipated    bool     `json:"is_participated"`      // 玩家是否參戰,入座 ≠ 參戰
	IsBetweenDealerBB bool     `json:"is_between_dealer_bb"` // 玩家入場時是否在 Dealer & BB 之間
	Bankroll          int64    `json:"bankroll"`             // 玩家身上籌碼
}

type TableState

type TableState struct {
	GameCount              int                 `json:"game_count"`                // 執行牌局遊戲次數 (遊戲跑幾輪)
	StartGameAt            int64               `json:"start_game_at"`             // 開打時間
	BlindState             *TableBlindState    `json:"blind_state"`               // 盲注狀態
	CurrentDealerSeatIndex int                 `json:"current_dealer_seat_index"` // 當前 Dealer 座位編號
	CurrentBBSeatIndex     int                 `json:"current_bb_seat_index"`     // 當前 BB 座位編號
	PlayerSeatMap          []int               `json:"player_seat_map"`           // 座位入座狀況,index: seat index (0-8), value: TablePlayerState index (-1 by default)
	PlayerStates           []*TablePlayerState `json:"player_states"`             // 賽局桌上玩家狀態
	PlayingPlayerIndexes   []int               `json:"playing_player_indexes"`    // 本手正在玩的 PlayerIndex 陣列 (陣列 index 為從 Dealer 位置開始的 PlayerIndex),GameEngine 用
	Status                 TableStateStatus    `json:"status"`                    // 當前桌次狀態
	Rankings               []int               `json:"ranks"`                     // 當桌即時排名, 名次: 陣列 index + 1, 陣列元素: player_idx, ex: [4, 0, 2]: 第一名: players[4], 第二名: players[0]...
	GameState              pokerface.GameState `json:"game_state"`                // 本手狀態 (pokerface.GameState)
}

type TableStateStatus

type TableStateStatus string
const (
	// TableStateStatus
	TableStateStatus_TableGameCreated                 TableStateStatus = "TableGame_Created"                 // 本桌遊戲已建立
	TableStateStatus_TableGameKilled                  TableStateStatus = "TableGame_Killed"                  // 本桌遊戲已被強制關閉
	TableStateStatus_TableGameAutoEnded               TableStateStatus = "TableGame_AutoEnded"               // 本桌遊戲已被自動關閉
	TableStateStatus_TableGamePaused                  TableStateStatus = "TableGame_Paused"                  // 本桌遊戲暫停
	TableStateStatus_TableGameRestoring               TableStateStatus = "TableGame_Restoring"               // 本桌遊戲轉移中 (Graceful Shutdown)
	TableStateStatus_TableGameClosed                  TableStateStatus = "TableGame_Closed"                  // 本桌遊戲結束
	TableStateStatus_TableGameMatchOpen               TableStateStatus = "TableGame_MatchOpen"               // 本手遊戲已開始
	TableStateStatus_TableGameWaitingDistributeTables TableStateStatus = "TableGame_WaitingDistributeTables" // 等待拆併桌
)

type Ticket

type Ticket struct {
	ID   string `json:"id"`   // ID
	Name string `json:"name"` // 名稱
}

Jump to

Keyboard shortcuts

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