models

package
v0.0.0-...-82afa91 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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 CreateAccount(db *mgo.Database, a Account) error

func DecrementCounter

func DecrementCounter(db *mgo.Database) (int, error)

func Disconnect

func Disconnect(accountID string)

func IncrementCounter

func IncrementCounter(db *mgo.Database) (int, error)

func InitializeConnectionManager

func InitializeConnectionManager(db *mgo.Database)

func InitializeHighCardManager

func InitializeHighCardManager()

func MapToStringKeys

func MapToStringKeys(m map[string]interface{}) []string

func RemovePlayerFromGames

func RemovePlayerFromGames(db *mgo.Database, accountID string) error

func Send

func Send(accountID string, msg interface{}) error

func SendAll

func SendAll(msg interface{}) error

func SendError

func SendError(accountID string, errMsg string)

func SendGame

func SendGame(db *mgo.Database, gameID string, msg interface{}) error

func SendGameError

func SendGameError(db *mgo.Database, gameID string, errMsg string)

func SqrtCounter

func SqrtCounter(db *mgo.Database) (int, error)

func SquareCounter

func SquareCounter(db *mgo.Database) (int, error)

func StringInSlice

func StringInSlice(str string, slice []string) bool

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 CheckSession(db *mgo.Database, sessionID string) (Account, error)

func LoadAccount

func LoadAccount(db *mgo.Database, username string) (Account, error)

func LoadAccountByID

func LoadAccountByID(db *mgo.Database, accountID string) (Account, error)

func (Account) ClearSession

func (a Account) ClearSession(db *mgo.Database) error

func (Account) NewSession

func (a Account) NewSession(db *mgo.Database) (string, error)

func (Account) Update

func (a Account) Update(db *mgo.Database) error

type ActionTo

type ActionTo struct {
	CallAmount int    `json:"callAmount"`
	AccountID  string `json:"accountID"`
}

type Card

type Card struct {
	Suit    `json:"suit"`
	Rank    int    `json:"rank"`
	Display string `json:"display"`
}

type Connection

type Connection struct {
	AccountID string
	SocketID  string
	Socket    *websocket.Conn
}

type ConnectionManager

type ConnectionManager struct {
	DB          *mgo.Database
	Connections map[string]*Connection //account id = Connection
}

type Counter

type Counter struct {
	Count int `json:"count" bson:"count"`
}

func LoadMathCount

func LoadMathCount(db *mgo.Database) (*Counter, error)

type Deck

type Deck struct {
	Cards []Card
	Index int
}

func NewDeck

func NewDeck() *Deck

func (*Deck) Deal

func (d *Deck) Deal() (*Card, error)

func (*Deck) Shuffle

func (d *Deck) Shuffle(shuffles int)

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

func CreateGame(db *mgo.Database, name, gameType string) (Game, error)

func JoinGame

func JoinGame(db *mgo.Database, gameID string, accountID string, buyinAmount int) (Game, error)

func LeaveGame

func LeaveGame(db *mgo.Database, gameID string, accountID string) (Game, error)

func LoadGame

func LoadGame(db *mgo.Database, gameID, gameName string) (Game, error)

func LoadGames

func LoadGames(db *mgo.Database) ([]Game, error)

func (Game) Update

func (g Game) Update(db *mgo.Database) error

type GamePlayer

type GamePlayer struct {
	AccountID string `json:"accountID" bson:"accountID"`
	Name      string `json:"name" bson:"name"`
	Chips     int    `json:"chips" bson:"chips"`
}

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 HighCardMessage struct {
	Type  string `json:"type"`
	Game  `json:"gameInfo"`
	State interface{} `json:"gameState"`
}

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 HoldemMessage struct {
	Message
	Game `json:"game"`
}

type Message

type Message struct {
	Type       string        `json:"type"`
	Raw        []byte        `json:"-"`
	Context    *echo.Context `json:"-"`
	Sender     Account       `json:"-"`
	Connection *Connection   `json:"-"`
}

type Rank

type Rank struct {
	Value   int
	Display string
}

type Suit

type Suit string

type TestStruct

type TestStruct struct {
	Name string
}

Jump to

Keyboard shortcuts

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