Documentation ¶
Index ¶
- Constants
- func DelRoom(room *Room)
- func Eva5Hand(cards [5]Card) int
- func Eva6Hand(cards [6]Card) int
- func Eva7Hand(cards [7]Card) int
- func NewRoomList() *roomlist
- func SetRoom(room *Room)
- type Auth
- type AuthResp
- type Card
- type Conn
- type Deck
- type Error
- type Message
- type Occupant
- func (o *Occupant) Betting(n int) (raised bool)
- func (o *Occupant) Broadcast(message *Message)
- func (o *Occupant) GetAction(timeout time.Duration) (*Message, error)
- func (o *Occupant) GetMessage(timeout time.Duration) (*Message, error)
- func (o *Occupant) Join(rid string) (room *Room)
- func (o *Occupant) Leave() (room *Room)
- func (o *Occupant) Next() *Occupant
- func (o *Occupant) SendError(code int, err string) error
- func (o *Occupant) SendMessage(message *Message) error
- type Poker
- type Room
- type Version
Constants ¶
View Source
const ( HgihCard = iota + 1 OnePair TwoPair ThreeOfAKind Straight Flush FullHouse FourOfAKind StraightFlush RoyalFlush )
View Source
const ( Deuce = iota Trey Four Five Six Seven Eight Nine Ten Jack Queen King Ace RankMask = 0xF )
rank
View Source
const ( Club = 0x8000 Diamond = 0x4000 Heart = 0x2000 Spade = 0x1000 SuitMask = 0xF000 )
suit
View Source
const ( MsgIQ = "iq" MsgPresence = "presence" MsgMessage = "message" ActGet = "get" ActSet = "set" ActResult = "result" ActPreflop = "preflop" ActFlop = "flop" ActTurn = "turn" ActRiver = "river" ActShowdown = "showdown" ActPot = "pot" ActActive = "active" ActJoin = "join" ActLeave = "gone" ActBet = "bet" ActButton = "button" ActState = "state" ActAction = "action" ActReady = "ready" ActCall = "call" ActCheck = "check" ActRaise = "raise" ActFold = "fold" ActAllin = "allin" )
View Source
const (
MaxN = 10
)
View Source
const NilCard = Card(0)
View Source
const (
NumCard = 52
)
Variables ¶
This section is empty.
Functions ¶
func NewRoomList ¶
func NewRoomList() *roomlist
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) ReadJSONTimeout ¶
type Deck ¶
type Deck struct {
// contains filtered or unexported fields
}
func (*Deck) Init ¶
func (deck *Deck) Init()
This routine initializes the deck. A deck of cards is simply an integer array of length 52 (no jokers). This array is populated with each card, using the following scheme:
An integer is made up of four bytes. The high-order bytes are used to hold the rank bit pattern, whereas the low-order bytes hold the suit/rank/prime value of the card.
+--------+--------+--------+--------+ |xxxbbbbb|bbbbbbbb|cdhsrrrr|xxpppppp| +--------+--------+--------+--------+
p = prime number of rank (deuce=2,trey=3,four=5,five=7,...,ace=41) r = rank of card (deuce=0,trey=1,four=2,five=3,...,ace=12) cdhs = suit of card b = bit turned on depending on rank of card
type Message ¶
type Message struct { Id string `json:"id,omitempty"` Type string `json:"type"` From string `json:"from,omitempty"` To string `json:"to,omitempty"` Action string `json:"action"` Class string `json:"class,omitempty"` Occupant *Occupant `json:"occupant,omitempty"` Room *Room `json:"room,omitempty"` Rooms []*Room `json:"rooms,omitempty"` }
type Occupant ¶
type Occupant struct { Id string `json:"id"` Name string `json:"name"` Profile string `json:"profile"` Level int `json:"level"` Chips int `json:"chips"` Pos int `json:"index,omitempty"` Bet int `json:"bet,omitempty"` Action string `json:"action,omitempty"` Cards []Card `json:"cards,omitempty"` Hand int `json:"hand,omitempty"` Room *Room `json:"-"` Actions chan *Message `json:"-"` // contains filtered or unexported fields }
func NewOccupant ¶
func (*Occupant) GetMessage ¶
func (*Occupant) SendMessage ¶
type Poker ¶
type Poker struct { WebRoot string Addr string OnAuth func(conn *Conn, mechanism, text string) (*Occupant, error) OnExit func(o *Occupant) }
func (*Poker) ListenAndServe ¶
type Room ¶
type Room struct { Id string `json:"id"` SB int `json:"sb"` BB int `json:"bb"` Cards []Card `json:"cards,omitempty"` Pot []int `json:"pot,omitempty"` Timeout int `json:"timeout,omitempty"` Button int `json:"button,omitempty"` Occupants []*Occupant `json:"occupants,omitempty"` Chips []int `json:"chips,omitempty"` Bet int `json:"bet,omitempty"` N int `json:"n"` Max int `json:"max"` MaxChips int `json:"maxchips"` MinChips int `json:"minchips"` EndChan chan int `json:"-"` // contains filtered or unexported fields }
func (*Room) AddOccupant ¶
func (*Room) DelOccupant ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.