nightfury

package
v0.0.0-...-22c49a1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

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

func Slug

func Slug(value string) string

Slug generate slug for the string

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) Add

func (c Client) Add(game Game)

Add attaches a game to the client

func (Client) CompleteGame

func (c Client) CompleteGame(game Game) error

CompleteGame completes a given game

func (Client) Connected

func (c Client) Connected() Client

Connected marks the client as available

func (Client) Delete

func (c Client) Delete(repo db.Repository) error

Delete deletes the client information to db

func (Client) Disconnected

func (c Client) Disconnected() Client

Disconnected marks the client as unavailable

func (Client) FailGame

func (c Client) FailGame(game Game) error

FailGame completes a given game

func (Client) HasNext

func (c Client) HasNext() bool

HasNext checks if there is any game to play

func (Client) ID

func (c Client) ID() string

ID returns the identifiable name for client

func (Client) Next

func (c Client) Next() (Game, error)

Next returns next ready game

func (Client) Remove

func (c Client) Remove(game Game)

Remove removes the game from the client

func (Client) Reset

func (c Client) Reset() error

Reset resets state of all games

func (Client) Save

func (c Client) Save(repo db.Repository) error

Save saves the client information to db

func (Client) Start

func (c Client) Start() (Game, error)

Start starts the first ready game, returns error if game is already started

func (Client) Status

func (c Client) Status() Status

Status represents Client status based on game status

type Clients

type Clients map[string]Client

Clients represents the collection of Client

func (Clients) Delete

func (c Clients) Delete(repo db.Repository) error

Delete deletes all the client information from 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

func (Game) Delete

func (g Game) Delete(repo db.Repository) error

Delete deletes the client information to db

func (Game) ID

func (g Game) ID() string

ID returns the identifiable name for client

func (Game) Save

func (g Game) Save(repo db.Repository) error

Save saves the client information to db

type GameStatus

type GameStatus struct {
	Name   string `json:"name"`
	Status Status `json:"status"`
}

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 Games

type Games map[string]Game

Games represents collection of games

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

func (hint Hint) DetectChangeInTitle(incidentToBeUpdated Hint) error

DetectChangeInTitle will return error if title changes during update

func (Hint) ID

func (hint Hint) ID() string

ID returns the identifiable name for client

func (Hint) Save

func (hint Hint) Save(repo db.Repository) error

Save saves the client information to db

type Hints

type Hints map[string]Hint

Hints represents collection of games

type Status

type Status int

Status represents different game status

const (
	// Ready represents game is available to play
	Ready Status = iota

	// InProgress represents game is in progress
	InProgress

	// Failed represents game has not been successfully completed
	Failed

	// Completed represents game has been successfully completed
	Completed
)

func (Status) String

func (status Status) String() string

String returns the string representation of status

Jump to

Keyboard shortcuts

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