Documentation ¶
Index ¶
- func NewClientsFromRepo(repo db.Repository) (interface{}, error)
- func NewGamesFromRepo(repo db.Repository) (interface{}, error)
- func NewHintsFromRepo(repo db.Repository) (interface{}, error)
- func Slug(value string) string
- type Client
- func (c Client) Add(game Game)
- func (c Client) CompleteGame(game Game) error
- func (c Client) Connected() Client
- func (c Client) Delete(repo db.Repository) error
- func (c Client) Disconnected() Client
- func (c Client) FailGame(game Game) error
- func (c Client) HasNext() bool
- func (c Client) ID() string
- func (c Client) Next() (Game, error)
- func (c Client) Remove(game Game)
- func (c Client) Reset() error
- func (c Client) Save(repo db.Repository) error
- func (c Client) Start() (Game, error)
- func (c Client) Status() Status
- type Clients
- type Game
- type GameStatus
- type GameStatuses
- type Games
- type Hint
- type Hints
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientsFromRepo ¶
func NewClientsFromRepo(repo db.Repository) (interface{}, error)
NewClientsFromRepo returns all the clients from db
func NewGamesFromRepo ¶
func NewGamesFromRepo(repo db.Repository) (interface{}, error)
NewGamesFromRepo returns all the clients from db
func NewHintsFromRepo ¶
func NewHintsFromRepo(repo db.Repository) (interface{}, error)
NewHintsFromRepo returns all the clients from db
Types ¶
type Client ¶
type Client struct { Name string `json:"name"` Available bool `json:"available"` GameStatuses GameStatuses `json:"gameStatuses"` }
Client represent the client from where the games are started
func NewClient ¶
func NewClient(name string, available bool, game ...GameStatus) Client
NewClient return a new instance of client with empty list of games
func NewClientFromRepoWithName ¶
func NewClientFromRepoWithName(repo db.Repository, name string) (Client, error)
NewClientFromRepoWithName return all the client from db
func (Client) CompleteGame ¶
CompleteGame completes a given game
func (Client) Delete ¶
func (c Client) Delete(repo db.Repository) error
Delete deletes the client information to db
func (Client) Disconnected ¶
Disconnected marks the client as unavailable
func (Client) Save ¶
func (c Client) Save(repo db.Repository) error
Save saves the client information to db
type Game ¶
type Game struct { Name string `json:"name" binding:"required"` Title string `json:"title"` Instruction string `json:"instruction" binding:"required"` Type string `json:"type" binding:"required"` Mode string `json:"mode"` Metadata map[string]interface{} `json:"metadata"` }
Game represents the game
func NewGameFromRepoWithName ¶
func NewGameFromRepoWithName(repo db.Repository, name string) (Game, error)
NewGameFromRepoWithName return all the client from db
type GameStatus ¶
GameStatus represents the game current status
func (GameStatus) Completed ¶
func (g GameStatus) Completed() (GameStatus, error)
Completed mark the status as completed
func (GameStatus) Failed ¶
func (g GameStatus) Failed() (GameStatus, error)
Failed mark the status as failed
func (GameStatus) InProgress ¶
func (g GameStatus) InProgress() (GameStatus, error)
InProgress mark the status as progress
type GameStatuses ¶
type GameStatuses map[string]GameStatus
GameStatuses represents the collection game current status
func (GameStatuses) HasReadyGames ¶
func (statuses GameStatuses) HasReadyGames() bool
HasReadyGames returns true if any game is in progress
func (GameStatuses) IsAnyGameInProgress ¶
func (statuses GameStatuses) IsAnyGameInProgress() bool
IsAnyGameInProgress returns true if any game is in progress
func (GameStatuses) ReadyGame ¶
func (statuses GameStatuses) ReadyGame() (Game, error)
ReadyGame returns ready game if any else returns error
type Hint ¶
type Hint struct { Title string `json:"title" binding:"required"` Tag []string `json:"tag" binding:"required"` Content string `json:"content" binding:"required"` Takeaway string `json:"takeaway" binding:"required"` }
Hint represents the hint
func NewHintFromRepoWithName ¶
func NewHintFromRepoWithName(repo db.Repository, name string) (Hint, error)
NewHintFromRepoWithName return all the client from db
func (Hint) Delete ¶
func (hint Hint) Delete(repo db.Repository) error
Delete deletes the client information to db
func (Hint) DetectChangeInTitle ¶
DetectChangeInTitle will return error if title changes during update