services

package
v0.0.0-...-d73c5c4 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CardService

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

func NewCardService

func NewCardService(logger Logger, repo repository.Cards, playerService Players, numOfDecks int) *CardService

func (*CardService) DrawCardFromDeckToDealer

func (c *CardService) DrawCardFromDeckToDealer(ctx context.Context, telegramChatID int64) (core.Card, error)

func (*CardService) DrawCardFromDeckToPlayer

func (c *CardService) DrawCardFromDeckToPlayer(
	ctx context.Context,
	telegramChatID int64,
	username string,
) (*core.Player, error)

type Cards

type Cards interface {
	DrawCardFromDeckToDealer(ctx context.Context, telegramChatID int64) (core.Card, error)
	DrawCardFromDeckToPlayer(ctx context.Context, telegramChatID int64, username string) (*core.Player, error)
}

type ChatService

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

func NewChatService

func NewChatService(logger Logger, repo repository.Chats) *ChatService

func (*ChatService) CheckChatExists

func (c *ChatService) CheckChatExists(ctx context.Context, telegramChatID int64) error

func (*ChatService) RegisterChat

func (c *ChatService) RegisterChat(ctx context.Context, telegramChatID int64) error

type Chats

type Chats interface {
	CheckChatExists(ctx context.Context, telegramChatID int64) error
	RegisterChat(ctx context.Context, telegramChatID int64) error
}

type Deps

type Deps struct {
	Config     *config.Config
	Repository *repository.Repository
	Logger
}

type GameService

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

func NewGameService

func NewGameService(
	logger Logger,
	repo repository.Games,
	statisticService Statistics,
	cardService Cards,
) *GameService

func (*GameService) CheckIfGameShouldBeFinished

func (g *GameService) CheckIfGameShouldBeFinished(ctx context.Context, telegramChatID int64) (bool, error)

func (*GameService) FinishGame

func (g *GameService) FinishGame(
	ctx context.Context,
	telegramChatID int64,
) (*core.Game, core.UsersStatistics, error)

func (*GameService) NewGame

func (g *GameService) NewGame(ctx context.Context, telegramChatID int64) (*core.Game, error)

type Games

type Games interface {
	CheckIfGameShouldBeFinished(ctx context.Context, telegramChatID int64) (bool, error)
	FinishGame(ctx context.Context, telegramChatID int64) (*core.Game, core.UsersStatistics, error)
	NewGame(ctx context.Context, telegramChatID int64) (*core.Game, error)
}

type Logger

type Logger interface {
	Error(err error)
}

type PlayerService

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

func NewPlayerService

func NewPlayerService(logger Logger, repo repository.Players) *PlayerService

func (*PlayerService) AddNewPlayer

func (p *PlayerService) AddNewPlayer(ctx context.Context, telegramChatID int64, player core.Player) error

func (*PlayerService) GetPlayer

func (p *PlayerService) GetPlayer(ctx context.Context, telegramChatID int64, username string) (*core.Player, error)

func (*PlayerService) StopDrawing

func (p *PlayerService) StopDrawing(
	ctx context.Context,
	telegramChatID int64,
	player *core.Player,
) error

type Players

type Players interface {
	AddNewPlayer(ctx context.Context, telegramChatID int64, player core.Player) error
	GetPlayer(ctx context.Context, telegramChatID int64, username string) (*core.Player, error)
	StopDrawing(ctx context.Context, telegramChatID int64, player *core.Player) error
}

type Services

type Services struct {
	Cards
	Chats
	Games
	Players
	Statistics
}

func NewServices

func NewServices(deps Deps) *Services

type StatisticService

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

func NewStatisticService

func NewStatisticService(logger Logger, repo repository.Statistic) *StatisticService

func (*StatisticService) GetStatistics

func (s *StatisticService) GetStatistics(
	ctx context.Context,
	telegramChatID int64,
) (core.UsersStatistics, error)

func (*StatisticService) IncrementStatistic

func (s *StatisticService) IncrementStatistic(
	ctx context.Context,
	telegramChatID int64,
	gameResult core.UsersStatistics,
) error

type Statistics

type Statistics interface {
	GetStatistics(ctx context.Context, telegramChatID int64) (core.UsersStatistics, error)
	IncrementStatistic(ctx context.Context, telegramChatID int64, gameResult core.UsersStatistics) error
}

Directories

Path Synopsis
Package mock_services is a generated GoMock package.
Package mock_services is a generated GoMock package.

Jump to

Keyboard shortcuts

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