models

package
v0.0.0-...-0a6770c Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusWait = 1 << iota
	StatusActive
	StatusFinished
	StatusUnknown
)

Variables

This section is empty.

Functions

func ApplyAction

func ApplyAction(gameId int, actionType game.ActionType, playerPosition int, actionValue int) (err error)

func CheckAI

func CheckAI(gameId int)

func CreateAIUsers

func CreateAIUsers(AIType int) (ids []int, err error)

func CreateActiveGame

func CreateActiveGame(playerIds []int, gameId int) (game *gamePackage.Game, err error)

func DeleteStat

func DeleteStat(id int) error

func GetAIUserId

func GetAIUserId(AIType, position int) (int, error)

func GetAIUserIds

func GetAIUserIds(AIType, playerCount int) (ids []int, err error)

func GetActionCount

func GetActionCount(gameId int) (int, error)

func GetAllStatuses

func GetAllStatuses() []int

func GetGamePlayers

func GetGamePlayers(gameIds []int) map[int]([]LobbyPlayer)

func GetUserNickNameById

func GetUserNickNameById(id int) string

func IntSliceToString

func IntSliceToString(slice []int) string

func JoinGame

func JoinGame(gameId int, userId int) (err error, status string)

func LeaveGame

func LeaveGame(gameId int, userId int) (string, error)

func NewAction

func NewAction(gameId int, action *gamePackage.Action) (err error)

func NewGameState

func NewGameState(gameId int, gameState *gamePackage.GameState, isInit bool) error

func NewStat

func NewStat(aiTypes []int, count int, saveDistrInExcel bool)

func QRead

func QRead(info *game.PlayerGameInfo) float64

func QUpdate

func QUpdate(gameState *game.GameState, result 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 ReadyStat

func ReadyStat(id int, stat *stats.Stat, saveDistrInExcel bool)

func RegisterDatabase

func RegisterDatabase(driverName string, dataSource string, maxIdle int, maxOpen int)

func SetGameFinishedStatus

func SetGameFinishedStatus(gameId int)

func StartStat

func StartStat(id int, aiTypes []int, count int, saveDistrInExcel bool)

func StatusName

func StatusName(status int) string

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 AIUser struct {
	Id     int `orm:"auto"`
	Type   int `orm:"column(type)"`
	UserId int `orm:"column(user_id)"`
}

func (*AIUser) TableName

func (user *AIUser) TableName() string

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

func (a *Action) TableIndex() [][]string

func (*Action) TableName

func (a *Action) TableName() string

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"`
}

func (*Game) TableName

func (g *Game) TableName() string

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 (gs *GameState) TableIndex() [][]string

func (*GameState) TableName

func (gs *GameState) TableName() string

func (*GameState) TableUnique

func (gs *GameState) TableUnique() [][]string

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 GetActiveGames(userId int) (games []LobbyGame)

func GetAllGames

func GetAllGames(userId int) (games []LobbyGame)

func GetFinishedGames

func GetFinishedGames(userId int) (games []LobbyGame)

func GetMyGames

func GetMyGames(userId int) (games []LobbyGame)

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)

func NewGame

func NewGame(userId int, playersCount int, status int, isAIGame bool) (gameItem LobbyGameItem, err error)

type LobbyPlayer

type LobbyPlayer struct {
	Id       int    `orm:"column(id)" json:"id"`
	NickName string `orm:"column(nick_name)" json:"nick_name"`
}

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 (p *Player) TableIndex() [][]string

func (*Player) TableName

func (p *Player) TableName() string

func (*Player) TableUnique

func (p *Player) TableUnique() [][]string

type PlayerCount

type PlayerCount struct {
	GameId int `orm:"column(game_id)"`
	Count  int `orm:"column(count)"`
}

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 (q *QData) TableIndex() [][]string

func (*QData) TableName

func (q *QData) TableName() string

func (*QData) TableUnique

func (q *QData) TableUnique() [][]string

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"`
}

func ReadStats

func ReadStats() (stats []Stat)

func (*Stat) TableName

func (stat *Stat) TableName() string

type User

type User struct {
	wetalk.User
}

type UserGame

type UserGame struct {
	Id int `orm:"column(game_id)"`
}

Jump to

Keyboard shortcuts

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