Documentation ¶
Index ¶
- Variables
- func Connect(connection *Connection, account Account)
- func CreateAccount(db *mgo.Database, a Account) error
- func DecrementCounter(db *mgo.Database) (int, error)
- func Disconnect(accountID string)
- func IncrementCounter(db *mgo.Database) (int, error)
- func InitializeConnectionManager(db *mgo.Database)
- func InitializeHighCardManager()
- func MapToStringKeys(m map[string]interface{}) []string
- func RemovePlayerFromGames(db *mgo.Database, accountID string) error
- func Send(accountID string, msg interface{}) error
- func SendAll(msg interface{}) error
- func SendError(accountID string, errMsg string)
- func SendGame(db *mgo.Database, gameID string, msg interface{}) error
- func SendGameError(db *mgo.Database, gameID string, errMsg string)
- func SqrtCounter(db *mgo.Database) (int, error)
- func SquareCounter(db *mgo.Database) (int, error)
- func StringInSlice(str string, slice []string) bool
- type Account
- type ActionTo
- type Card
- type Connection
- type ConnectionManager
- type Counter
- type Deck
- type Game
- func CreateGame(db *mgo.Database, name, gameType string) (Game, error)
- func JoinGame(db *mgo.Database, gameID string, accountID string, buyinAmount int) (Game, error)
- func LeaveGame(db *mgo.Database, gameID string, accountID string) (Game, error)
- func LoadGame(db *mgo.Database, gameID, gameName string) (Game, error)
- func LoadGames(db *mgo.Database) ([]Game, error)
- type GamePlayer
- type HighCardGame
- func (hcg *HighCardGame) Bet(amount int) error
- func (hcg *HighCardGame) Call() error
- func (hcg *HighCardGame) Check() error
- func (hcg *HighCardGame) Fold() error
- func (hcg *HighCardGame) NewHand() error
- func (hcg *HighCardGame) OnePlayerRemains() bool
- func (hcg *HighCardGame) Raise(raiseAmount int) error
- func (hcg *HighCardGame) Send() error
- func (hcg *HighCardGame) StartHand() error
- func (hcg *HighCardGame) Transition(state string) error
- type HighCardHand
- type HighCardManager
- type HighCardMessage
- type HighCardPlayer
- type HoldemMessage
- type Message
- type Rank
- type Suit
- type TestStruct
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //holdem actions HoldemStart = "HOLDEMSTART" HoldemActions = []string{HoldemStart} )
type Player struct{ AccountID string Chips int }
type State struct{ CurrentPlayers []Player ActivePlayer string }
type Bet
type Hand struct{ Pot int Bank int State State Actions []interface }
type Holdem struct { ID string `json:"gameID" bson:"gameID"` Bank int `json:"-" bson:"bank"` Hands []Hand `json:"players" bson:"players"` }
View Source
var (
AccountNotFound = errors.New("account not found")
)
Functions ¶
func Connect ¶
func Connect(connection *Connection, account Account)
func CreateAccount ¶
func DecrementCounter ¶
func Disconnect ¶
func Disconnect(accountID string)
func IncrementCounter ¶
func InitializeConnectionManager ¶
func InitializeConnectionManager(db *mgo.Database)
func InitializeHighCardManager ¶
func InitializeHighCardManager()
func MapToStringKeys ¶
func RemovePlayerFromGames ¶
func SendGameError ¶
func SqrtCounter ¶
func SquareCounter ¶
func StringInSlice ¶
Types ¶
type Account ¶
type Account struct { AccountID string `json:"-" bson:"accountID"` Balance int `json:"balance" bson:"balance"` Username string `json:"username" bson:"username"` Password string `json:"-" bson:"-"` Hashword string `json:"-" bson:"password"` SessionID string `json:"-" bson:"sessionID"` }
func CheckSession ¶
func LoadAccount ¶
func LoadAccountByID ¶
func (Account) ClearSession ¶
func (Account) NewSession ¶
type Connection ¶
type ConnectionManager ¶
type ConnectionManager struct { DB *mgo.Database Connections map[string]*Connection //account id = Connection }
type Game ¶
type Game struct { ID string `json:"gameID" bson:"gameID"` Name string `json:"gameName" bson:"gameName"` //State string `json:"state" bson:"state"` Players []GamePlayer `json:"players" bson:"players"` GameType string `json:"gameType" bson:"gameType"` }
func CreateGame ¶
type GamePlayer ¶
type HighCardGame ¶
type HighCardGame struct { Game Hands []*HighCardHand Hand *HighCardHand Ante int }
func LoadCreateHighCardGame ¶
func LoadCreateHighCardGame(db *mgo.Database, gameID string) (*HighCardGame, error)
func (*HighCardGame) Bet ¶
func (hcg *HighCardGame) Bet(amount int) error
func (*HighCardGame) Call ¶
func (hcg *HighCardGame) Call() error
func (*HighCardGame) Check ¶
func (hcg *HighCardGame) Check() error
func (*HighCardGame) Fold ¶
func (hcg *HighCardGame) Fold() error
func (*HighCardGame) NewHand ¶
func (hcg *HighCardGame) NewHand() error
func (*HighCardGame) OnePlayerRemains ¶
func (hcg *HighCardGame) OnePlayerRemains() bool
func (*HighCardGame) Raise ¶
func (hcg *HighCardGame) Raise(raiseAmount int) error
func (*HighCardGame) Send ¶
func (hcg *HighCardGame) Send() error
func (*HighCardGame) StartHand ¶
func (hcg *HighCardGame) StartHand() error
func (*HighCardGame) Transition ¶
func (hcg *HighCardGame) Transition(state string) error
type HighCardHand ¶
type HighCardHand struct { PlayerList []*HighCardPlayer `json:"players"` Players map[string]*HighCardPlayer `json:"-"` *Deck `json:"-"` Pot int `json:"pot"` ActionTo `json:"actionTo"` Complete bool `json:"complete"` Payout int `json:"payout"` //only set if complete==true NumTurns int `json:"-"` NumStartPlayers int `json:"-"` }
type HighCardManager ¶
type HighCardManager struct {
Games map[string]*HighCardGame
}
type HighCardMessage ¶
type HighCardPlayer ¶
type HighCardPlayer struct { Next *HighCardPlayer `json:"-"` GamePlayer `json:"gamePlayer"` Card `json:"card"` State string `json:"state"` }
func (*HighCardPlayer) Copy ¶
func (hcp *HighCardPlayer) Copy() *HighCardPlayer
type HoldemMessage ¶
type TestStruct ¶
type TestStruct struct {
Name string
}
Click to show internal directories.
Click to hide internal directories.