store

package
v0.0.0-...-7a66c0d Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	// contains filtered or unexported fields
}

func (*Game) Close

func (g *Game) Close(ch <-chan struct{}) error

func (*Game) GetGameState

func (g *Game) GetGameState(playerID string) (*GameState, error)

func (*Game) PlayMove

func (g *Game) PlayMove(m game.Move) error

func (*Game) UUID

func (g *Game) UUID() string

type GameService

type GameService struct {
	*Store
	// contains filtered or unexported fields
}

func NewGameService

func NewGameService(dbFilename string) (*GameService, error)

func (*GameService) CloseGames

func (s *GameService) CloseGames(notifs []NewGameNotification)

func (*GameService) CloseNewGameCh

func (s *GameService) CloseNewGameCh(playerID string)

func (*GameService) ListenAny

func (s *GameService) ListenAny(notifs []NewGameNotification, ctx context.Context) <-chan int

func (*GameService) NewGame

func (s *GameService) NewGame(playerX string, playerO string) error

func (*GameService) OpenGamesForPlayer

func (s *GameService) OpenGamesForPlayer(playerUUID string) ([]NewGameNotification, <-chan NewGameNotification, error)

type GameState

type GameState struct {
	GameID  string `json:"gameID"`
	PlayerX string `json:"playerX"`
	PlayerO string `json:"playerO"`

	PlayerXName string `json:"playerXName"`
	PlayerOName string `json:"playerOName"`

	Victor *string         `json:"victor"`
	Grids  [3][3]GridState `json:"grids"`
}

type GridState

type GridState struct {
	Owner   *string           `json:"owner"`
	Squares [3][3]SquareState `json:"squares"`
}

type NewGameNotification

type NewGameNotification struct {
	Game     *Game
	UpdateCh <-chan struct{}
}

type Player

type Player struct {
	UUID, Username, GoogleID string
}

type SquareState

type SquareState struct {
	Owner      *string         `json:"owner"`
	Playable   bool            `json:"playable"`
	Coordinate game.Coordinate `json:"coordinate"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(filepath string) (*Store, error)

func (*Store) CreatePlayer

func (s *Store) CreatePlayer(username string, googleID string) (*Player, error)

func (*Store) TryLookupPlayer

func (s *Store) TryLookupPlayer(googleID string) (*Player, error)

func (*Store) TryLookupPlayerUUID

func (s *Store) TryLookupPlayerUUID(id string) (*Player, error)

func (*Store) TryLookupPlayerUsername

func (s *Store) TryLookupPlayerUsername(username string) (*Player, error)

Jump to

Keyboard shortcuts

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