game

package
v0.0.0-...-f9bed8c Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context = *state.Context[*PlayerState]

type Game

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

func NewGame

func NewGame(
	ctx context.Context,
	gameID string,
	server state.Server[*PlayerState],
	gameCase *usecore.Game,
	playerCase *usecore.Player,
	routeCase *usecore.Route,
	pollRepo repo.Poll,
	voteRepo repo.Vote,
	completedTaskPointRepo repo.CompletedTaskPoint,
) (*Game, error)

func (*Game) Active

func (g *Game) Active() bool

func (*Game) OnBroadcast

func (g *Game) OnBroadcast(c Context, ev event.Broadcast) error

func (*Game) OnDisconnect

func (g *Game) OnDisconnect(c Context) error

func (*Game) OnFinishGame

func (g *Game) OnFinishGame(c Context, ev event.FinishGame) error

func (*Game) OnFinishGameApprove

func (g *Game) OnFinishGameApprove(c Context, ev event.FinishGameApprove) error

func (*Game) OnFinishGameReject

func (g *Game) OnFinishGameReject(c Context, ev event.FinishGameReject) error

func (*Game) OnJoinGame

func (g *Game) OnJoinGame(c Context) error

func (*Game) OnLocationUpdate

func (g *Game) OnLocationUpdate(c Context, ev event.LocationUpdate) error

func (*Game) OnPause

func (g *Game) OnPause(c Context, ev event.Pause) error

func (*Game) OnPlayerCatch

func (g *Game) OnPlayerCatch(c Context, ev event.PlayerCatch) error

func (*Game) OnPlayerCatchApprove

func (g *Game) OnPlayerCatchApprove(c Context, ev event.PlayerCatchApprove) error

func (*Game) OnPlayerCatchReject

func (g *Game) OnPlayerCatchReject(c Context, ev event.PlayerCatchReject) error

func (*Game) OnSetRoute

func (g *Game) OnSetRoute(c Context, ev event.SetRoute) error

func (*Game) OnStartGame

func (g *Game) OnStartGame(c Context, _ event.StartGame) error

func (*Game) OnTaskApprove

func (g *Game) OnTaskApprove(c Context, ev event.TaskApprove) error

func (*Game) OnTaskComplete

func (g *Game) OnTaskComplete(c Context, ev event.TaskComplete) error

func (*Game) OnTaskReject

func (g *Game) OnTaskReject(c Context, ev event.TaskReject) error

func (*Game) OnUnpause

func (g *Game) OnUnpause(c Context, _ event.Unpause) error

type Handler

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

func NewHandler

func NewHandler(gameProvider *InMemoryGameRepo, userCase *usecore.User, auth *auth.Auth) *Handler

func (*Handler) Handle

func (h *Handler) Handle(c Context, e state.AnyEvent) error

func (*Handler) OnAuth

func (h *Handler) OnAuth(c Context, ev event.Auth) error

func (*Handler) OnConnect

func (h *Handler) OnConnect(c Context) error

func (*Handler) OnDisconnect

func (h *Handler) OnDisconnect(c Context) error

func (*Handler) OnJoinGame

func (h *Handler) OnJoinGame(c Context, ev event.JoinGame) error

func (*Handler) OnLeaveGame

func (h *Handler) OnLeaveGame(c Context, _ event.LeaveGame) error

func (*Handler) RegisteredEvents

func (h *Handler) RegisteredEvents() []string

type InMemoryGameRepo

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

func NewInMemoryGameRepo

func NewInMemoryGameRepo(
	ctx context.Context,
	gameCase *usecore.Game,
	playerCase *usecore.Player,
	routeCase *usecore.Route,
	pollRepo repo.Poll,
	voteRepo repo.Vote,
	completedTaskPointRepo repo.CompletedTaskPoint,
) *InMemoryGameRepo

func (*InMemoryGameRepo) DeleteGame

func (r *InMemoryGameRepo) DeleteGame(ctx context.Context, id string) error

func (*InMemoryGameRepo) GetGame

func (r *InMemoryGameRepo) GetGame(ctx context.Context, id string, server state.Server[*PlayerState]) (*Game, error)

type PlayerState

type PlayerState struct {
	User   *domain.User
	Player *domain.Player
	Game   *Game
}

Jump to

Keyboard shortcuts

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