Documentation
¶
Index ¶
- Constants
- func GetLogger() *logging.Logger
- func StartGateway()
- type Card
- type CardCollection
- type CardFace
- type CardFaceType
- type CardsCheck
- type Game
- type GameStatus
- type MessageType
- type Player
- type PlayerConn
- type PlayerConnection
- type PlayerStatus
- type RequestMessage
- type ResponseMessage
- type SortByValue
Constants ¶
const ( Card_K = 12 Card_Q = 11 Card_J = 10 Card_10 = 9 Card_9 = 8 Card_8 = 7 Card_7 = 6 Card_6 = 5 Card_5 = 4 Card_4 = 3 Card_3 = 2 Card_2 = 1 Card_A = 0 Card_None = -1 )
card index
const (
MAX_GROUP_PLAYER int = 10
)
it's just a game
const (
RESULT_OK = 0
)
Variables ¶
This section is empty.
Functions ¶
func StartGateway ¶
func StartGateway()
Types ¶
type CardCollection ¶
type CardCollection uint64
represents a collection of cards in 64 bits Spade [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A] at bit [61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48] Hearts [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A] at bit [45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32] Clubs [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A] at bit [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16] Diamond [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A] at bit [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
func NewCardCollection ¶
func NewCardCollection(cc []Card) CardCollection
func (*CardCollection) CardExists ¶
func (cc *CardCollection) CardExists(c Card) bool
func (*CardCollection) SetCard ¶
func (cc *CardCollection) SetCard(c Card)
type CardFaceType ¶
type CardFaceType int8
牌型
const ( //RoyalFlush CardFaceType = 9 //皇家同花顺 StraightFlush CardFaceType = 8 //同花顺 FourOfAKind CardFaceType = 7 //四条 FullHouse CardFaceType = 6 //葫芦 Flush CardFaceType = 5 //同花 Straight CardFaceType = 4 //顺子 ThreeOfAKind CardFaceType = 3 //三条 TwoPairs CardFaceType = 2 //两队 Pair CardFaceType = 1 //一对 HighCard CardFaceType = 0 //高牌 CardFaceNone CardFaceType = -1 )
func (CardFaceType) String ¶
func (ct CardFaceType) String() string
type CardsCheck ¶
type CardsCheck struct {
// contains filtered or unexported fields
}
func NewCardsCheck ¶
func NewCardsCheck(cc []Card) *CardsCheck
func NewCardsCheckFromCC ¶
func NewCardsCheckFromCC(cc CardCollection) *CardsCheck
func (*CardsCheck) CardCollection ¶
func (ck *CardsCheck) CardCollection() CardCollection
func (*CardsCheck) CardFace ¶
func (ck *CardsCheck) CardFace() CardFaceType
func (*CardsCheck) CmpTo ¶
func (ck *CardsCheck) CmpTo(ck2 *CardsCheck) int
returns: big 1, equal 0, small -1
func (*CardsCheck) Top5Cards ¶
func (ck *CardsCheck) Top5Cards() []Card
func (*CardsCheck) TopCards ¶
func (ck *CardsCheck) TopCards() []Card
returns the top cards(high cards not included.) for example: there're 4 cards returned when CardFaceType is FourOfAKind
type Game ¶
type Game struct {
Id int
//1到多个玩家
Players []*Player
//随机排序的牌
ShuffledCards []*Card
//当前游戏的状态
Status GameStatus
//公共牌
Cards []*Card
//specify who is the dealer button. the dealer button rotates clockwise after each hand
//the one next to the dealer button is small blind. and the one next to small blind is big blind
Dealer int
// contains filtered or unexported fields
}
represents a Game
type GameStatus ¶
type GameStatus int
游戏状态
const ( //创建了, 但是还没开始 GameNew GameStatus = 0 //游戏当中 GameInPlay GameStatus = 1 //游戏结束 GameOver GameStatus = 2 // GameToBeDestroy GameStatus = 3 )
type MessageType ¶
type MessageType int
const ( //server actions. server -> player HoleCards MessageType = 20 //2 cards face down to each player Flop MessageType = 20 + 1 //show 3 common cards. all players choose bet or fold after hole cards Turn MessageType = 20 + 2 //show 1 common card after flop River MessageType = 20 + 3 //show 1 common card after turn //player actions. player -> server Check MessageType = 30 //player check Bet MessageType = 30 + 1 //player bet Raise MessageType = 30 + 2 //player raise Fold MessageType = 30 + 3 //player fold )
type Player ¶
type Player struct {
UserId int //player id. unique
Name string //player name
Counter int //palyer counter
Status PlayerStatus //玩家是否准备好开始
Cards []*Card //玩家的牌
Conn *PlayerConn //客户端连接
// contains filtered or unexported fields
}
type PlayerConn ¶
type PlayerConn struct {
// contains filtered or unexported fields
}
func (*PlayerConn) DoRequest ¶
func (pc *PlayerConn) DoRequest(req *RequestMessage) (*ResponseMessage, error)
type PlayerConnection ¶
type PlayerStatus ¶
type PlayerStatus int
玩家状态
const ( PlayerConnected PlayerStatus = 0 //玩家已连接, 尚未开始 PlayerReady PlayerStatus = 1 //玩家准备好, 可以开始玩游戏了 PlayerInPlay PlayerStatus = 2 //玩家游戏中 PlayerGaveup PlayerStatus = 3 //玩家选择放弃已投筹码, 不继续玩 )
type RequestMessage ¶
type RequestMessage struct {
MsgId int `json:"msgid"`
MsgType MessageType `json:"msgtype"`
Payload interface{} `json:"payload"`
}
type ResponseMessage ¶
type ResponseMessage struct {
RequestId int `json:"requestid"`
MsgType MessageType `json:"msgtype"`
Result int `json:"result"`
Payload interface{} `json:"payload"`
}
type SortByValue ¶
type SortByValue []Card
func (SortByValue) Len ¶
func (a SortByValue) Len() int
func (SortByValue) Less ¶
func (a SortByValue) Less(i, j int) bool
func (SortByValue) Swap ¶
func (a SortByValue) Swap(i, j int)