Documentation
¶
Index ¶
- Constants
- func ApplyAction(gameId int, actionType game.ActionType, playerPosition int, actionValue int) (err error)
- func CheckAI(gameId int)
- func CreateAIUsers(AIType int) (ids []int, err error)
- func CreateActiveGame(playerIds []int, gameId int) (game *gamePackage.Game, err error)
- func DeleteStat(id int) error
- func GetAIUserId(AIType, position int) (int, error)
- func GetAIUserIds(AIType, playerCount int) (ids []int, err error)
- func GetActionCount(gameId int) (int, error)
- func GetAllStatuses() []int
- func GetGamePlayers(gameIds []int) map[int]([]LobbyPlayer)
- func GetUserNickNameById(id int) string
- func IntSliceToString(slice []int) string
- func JoinGame(gameId int, userId int) (err error, status string)
- func LeaveGame(gameId int, userId int) (string, error)
- func NewAction(gameId int, action *gamePackage.Action) (err error)
- func NewGameState(gameId int, gameState *gamePackage.GameState, isInit bool) error
- func NewStat(aiTypes []int, count int, saveDistrInExcel bool)
- func QRead(info *game.PlayerGameInfo) float64
- func QUpdate(gameState *game.GameState, result float64)
- func ReadActions(gameId int) ([]gamePackage.Action, error)
- func ReadCurrentGameState(gameId int) (gameState gamePackage.GameState, err error)
- func ReadInitialGameState(gameId int) (gameState gamePackage.GameState, err error)
- func ReadyStat(id int, stat *stats.Stat, saveDistrInExcel bool)
- func RegisterDatabase(driverName string, dataSource string, maxIdle int, maxOpen int)
- func SetGameFinishedStatus(gameId int)
- func StartStat(id int, aiTypes []int, count int, saveDistrInExcel bool)
- func StatusName(status int) string
- func UpdateGameState(gameId int, gameState *gamePackage.GameState) error
- func UpdateInitGameState(gameId int, gameState *gamePackage.GameState) error
- func UpdatePoints(gameId int)
- type AIUser
- type Action
- type Game
- type GameState
- type LobbyGame
- type LobbyGameItem
- type LobbyPlayer
- type Player
- type PlayerCount
- type QData
- type Stat
- type User
- type UserGame
Constants ¶
View Source
const ( StatusWait = 1 << iota StatusActive StatusFinished StatusUnknown )
Variables ¶
This section is empty.
Functions ¶
func ApplyAction ¶
func CreateAIUsers ¶
func CreateActiveGame ¶
func CreateActiveGame(playerIds []int, gameId int) (game *gamePackage.Game, err error)
func DeleteStat ¶
func GetAIUserId ¶
func GetAIUserIds ¶
func GetActionCount ¶
func GetAllStatuses ¶
func GetAllStatuses() []int
func GetGamePlayers ¶
func GetGamePlayers(gameIds []int) map[int]([]LobbyPlayer)
func GetUserNickNameById ¶
func IntSliceToString ¶
func NewGameState ¶
func NewGameState(gameId int, gameState *gamePackage.GameState, isInit bool) error
func QRead ¶
func QRead(info *game.PlayerGameInfo) float64
func ReadActions ¶
func ReadActions(gameId int) ([]gamePackage.Action, error)
func ReadCurrentGameState ¶
func ReadCurrentGameState(gameId int) (gameState gamePackage.GameState, err error)
func ReadInitialGameState ¶
func ReadInitialGameState(gameId int) (gameState gamePackage.GameState, err error)
func RegisterDatabase ¶
func SetGameFinishedStatus ¶
func SetGameFinishedStatus(gameId int)
func StatusName ¶
func UpdateGameState ¶
func UpdateGameState(gameId int, gameState *gamePackage.GameState) error
func UpdateInitGameState ¶
func UpdateInitGameState(gameId int, gameState *gamePackage.GameState) error
func UpdatePoints ¶
func UpdatePoints(gameId int)
Types ¶
type AIUser ¶
type Action ¶
type Action struct {
Id int `orm:"auto"`
GameId int `orm:"column(game_id)"`
Game *Game `orm:"-"`
Type int `orm:"column(action_type)"`
Position int `orm:"column(player_position)"`
Value int `orm:"column(value)"`
}
func (*Action) TableIndex ¶
type Game ¶
type Game struct {
Id int `orm:"auto" json:"id"`
OwnerId int `orm:"column(owner_id)" json:"owner_id"`
PlayerCount int `orm:"column(player_count)" json:"player_count"`
Status int `orm:"column(status);default(4)" json:"status"`
Points int `orm:"column(points);default(0)"`
Seed int64 `orm:"column(seed);null"`
IsAI bool `orm:"column(is_ai_only_game)"`
InitState *GameState `orm:"-"`
CurrentState *GameState `orm:"-"`
Actions []*Action `orm:"-"`
CreatedAt time.Time `orm:"column(created_at);auto_now_add;type(timestamp)" json:"created_at"`
}
type GameState ¶
type GameState struct {
Id int `orm:"auto"`
GameId int `orm:"column(game_id)"`
Game *Game `orm:"-"`
IsInit bool `orm:"column(is_init_state)"`
Json string `orm:"column(json);type(text)"`
}
func (*GameState) TableIndex ¶
func (*GameState) TableUnique ¶
type LobbyGame ¶
type LobbyGame struct {
Id int `json:"id" orm:"column(id)"`
PlayerCount int `json:"player_count" orm:"column(player_count)"`
OwnerId int `json:"owner_id" orm:"column(owner_id)"`
OwnerName string `json:"owner_name" orm:"column(owner_name)"`
Status int `json:"status" orm:"column(status)"`
StatusName string `json:"status_name"`
Points int `json:"points"`
CreatedAt time.Time `json:"created_at" orm:"column(created_at)"`
UserIn bool `json:"user_in"`
Players []LobbyPlayer `json:"players"`
URL string `json:"URL"`
}
func GetActiveGames ¶
func GetAllGames ¶
func GetFinishedGames ¶
func GetMyGames ¶
type LobbyGameItem ¶
type LobbyGameItem struct {
Id int `orm:"column(id)"`
OwnerId int `orm:"column(owner_id)"`
Owner string `orm:"column(owner)"`
StatusCode int `orm:"column(status)"`
Status string ``
PlayerCount int `orm:"column(count)"`
Players []LobbyPlayer ``
UserIn bool ``
URL string ``
Created time.Time `orm:"column(created)"`
}
func GetGameList ¶
func GetGameList(status []int, userId int) (games []LobbyGameItem)
type LobbyPlayer ¶
type Player ¶
type Player struct {
Id int `orm:"auto"`
UserId int `orm:"default(0);column(user_id)"`
GameId int `orm:"default(0);column(game_id)"`
}
func (*Player) TableIndex ¶
func (*Player) TableUnique ¶
type PlayerCount ¶
type QData ¶
type QData struct {
Id int `orm:"auto"`
PlayersCount int `orm:"column(players_count)"`
BlueTokens int `orm:"column(blue_tokens)"`
RedTokens int `orm:"column(red_tokens)"`
DeckSize int `orm:"column(deck_size)"`
StepLeft int `orm:"column(step_left)"`
InfoCount int `orm:"column(info_count)"`
Points int `orm:"column(points)"`
Count int `orm:"column(count);default(0)"`
Result float64 `orm:"column(result);default(25)"`
}
func (*QData) TableIndex ¶
func (*QData) TableUnique ¶
type Stat ¶
type Stat struct {
Id int `orm:"auto" json:"id"`
PlayerCount int `orm:"column(player_count)" json:"player_count"`
AITypesJSON string `orm:"column(ai_types)" json:"-"`
AITypes []int `orm:"-" json:"ai_types"`
AINames []string `orm:"-" json:"ai_names"`
GameCount int `orm:"column(count)" json:"count"`
WinCount int `orm:"column(win_count);default(0)" json:"-"`
Wins float64 `orm:"-" json:"wins"`
Points float64 `orm:"column(points);null" json:"points"`
Dispersion float64 `orm:"column(dispersion);null" json:"dispersion"`
Kurtosis float64 `orm:"column(kurtosis);null" json:"curtosis"`
Asymmetry float64 `orm:"column(asymmenty);null" json:"asymmetry"`
Ready time.Time `orm:"column(ready_at);null" json:"-"`
IsMetadata bool `orm:"column(is_metadata)" json:"is_metadata"`
ReadyStr string `orm:"-" json:"ready_at"`
Created time.Time `orm:"column(created_at)" json:"-"`
CreatedStr string `orm:"-" json:"created_at"`
ExecTime int `orm:"-" json:"execution_time"`
ReadyPart int `orm:"column(ready_part);default(0)" json:"-"`
ReadyJSON float64 `orm:"-" json:"ready_part"`
IsReady bool `orm:"-" json:"is_ready"`
}
Click to show internal directories.
Click to hide internal directories.