game

package
v0.3.22 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.3.2

type Config struct {
	ScanInterval time.Duration
}

type MarsClient

type MarsClient interface {
	CreateGame(ctx context.Context, game mars.CreateGameRequest) (mars.CreateGameResponse, error)
	GetGame(ctx context.Context, req mars.GetGameRequest) (mars.GetGameResponse, error)
	GetPlayerUrl(playerId string) string
	WaitingFor(ctx context.Context, req mars.WaitingForRequest) (mars.WaitingForResponse, error)
}

type Service

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

func NewService

func NewService(cfg Config, storage Storage, mars MarsClient) *Service

func (*Service) CreateGame

func (s *Service) CreateGame(ctx context.Context, users []*storage.User, settings mars.GameSettings) error

func (*Service) GetUserGames

func (s *Service) GetUserGames(inctx context.Context, userId string) ([]*UserGame, error)

func (*Service) NotifyGameFinished added in v0.3.21

func (s *Service) NotifyGameFinished(ctx context.Context, gameId string) error

func (*Service) ProcessElo added in v0.3.16

func (s *Service) ProcessElo(ctx context.Context) error

func (*Service) ProcessFinishedGames added in v0.3.16

func (s *Service) ProcessFinishedGames(ctx context.Context) error

type Storage

type Storage interface {
	CreateGame(ctx context.Context, game *storage.Game) error
	GetActiveGames(ctx context.Context) ([]*storage.Game, error)
	GetGamesByUserId(ctx context.Context, userId string, finishedWindow time.Duration) ([]*storage.Game, error)
	UpdateElo(ctx context.Context, updater storage.EloUpdater) error
	UpdateGameResults(ctx context.Context, gameId string, results *storage.GameResults) error
}

type UserGame

type UserGame struct {
	PlayURL      string
	CreatedAt    time.Time
	ExpiresAt    time.Time
	PlayersCount int
	AwaitsInput  bool
	HasFinished  bool
}

Jump to

Keyboard shortcuts

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