models

package
v0.0.0-...-e4f1321 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AIKind      = "AI"
	AIErrorKind = "AIError"
	AllAIsKey   = "AIs{All}"
)
View Source
const (
	GameKind = "Game"
)
View Source
const (
	TurnKind = "Turn"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AI

type AI struct {
	Id        *datastore.Key
	URL       string
	Name      string
	Games     int
	Wins      int
	Losses    int
	Owner     string `json:"-"`
	IsOwner   bool   `datastore:"-"`
	CreatedAt time.Time
}

func GetAIById

func GetAIById(c common.Context, id *datastore.Key) *AI

func (*AI) AddError

func (self *AI) AddError(c common.Context, turnId *datastore.Key, err error)

func (*AI) Delete

func (self *AI) Delete(c common.Context)

func (*AI) GetErrors

func (self *AI) GetErrors(c common.Context) (result AIErrors)

func (*AI) Save

func (self *AI) Save(c common.Context) *AI

type AIError

type AIError struct {
	Turn              *datastore.Key
	Game              *datastore.Key `datastore:"-"`
	Error             string         `datastore:"-"`
	ErrorDetail1      string         `datastore:"-"`
	ErrorDetail2      string         `datastore:"-"`
	ErrorBytes        []byte         `json:"-"`
	ErrorDetail1Bytes []byte         `json:"-"`
	ErrorDetail2Bytes []byte         `json:"-"`
	CreatedAt         time.Time
}

type AIErrors

type AIErrors []AIError

func (AIErrors) Len

func (self AIErrors) Len() int

func (AIErrors) Less

func (self AIErrors) Less(j, i int) bool

func (AIErrors) Swap

func (self AIErrors) Swap(i, j int)

type AIs

type AIs []AI

func GetAllAIs

func GetAllAIs(c common.Context) (result AIs)

func (AIs) Len

func (self AIs) Len() int

func (AIs) Less

func (self AIs) Less(i, j int) bool

func (AIs) Swap

func (self AIs) Swap(i, j int)

type Game

type Game struct {
	Id          *datastore.Key
	Players     []*datastore.Key
	Winner      *datastore.Key
	State       GameState
	PlayerNames []string `datastore:"-"`
	WinnerName  string   `datastore:"-"`
	Length      int
	CreatedAt   time.Time
}

func GetGameById

func GetGameById(c common.Context, id *datastore.Key) (result *Game)

func (*Game) Save

func (self *Game) Save(c common.Context) *Game

type GamePage

type GamePage struct {
	Content Games
	Total   int
}

func GetGamePage

func GetGamePage(c common.Context, offset, limit int) (result GamePage)

type GameState

type GameState string
const (
	StateCreated  GameState = "Created"
	StatePlaying  GameState = "Playing"
	StateFinished GameState = "Finished"
)

type Games

type Games []Game

func (Games) Len

func (self Games) Len() int

func (Games) Less

func (self Games) Less(j, i int) bool

func (Games) Swap

func (self Games) Swap(i, j int)

type Turn

type Turn struct {
	Id              *datastore.Key
	Ordinal         int
	SerializedState []byte       `json:"-"`
	State           *state.State `datastore:"-"`
	CreatedAt       time.Time
}

func GetGivenTurnByParent

func GetGivenTurnByParent(c common.Context, parent *datastore.Key, ordinal int) *Turn

func GetLatestTurnByParent

func GetLatestTurnByParent(c common.Context, parent *datastore.Key) *Turn

func (*Turn) Next

func (self *Turn) Next(c common.Context, orderMap map[state.PlayerId]state.Orders) (*Turn, *state.PlayerId)

func (*Turn) Save

func (self *Turn) Save(c common.Context, parent *datastore.Key) *Turn

type Turns

type Turns []Turn

func GetTurnsByParent

func GetTurnsByParent(c common.Context, parent *datastore.Key) (result Turns)

func (Turns) Len

func (self Turns) Len() int

func (Turns) Less

func (self Turns) Less(i, j int) bool

func (Turns) Swap

func (self Turns) Swap(i, j int)

Jump to

Keyboard shortcuts

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