game

package
v0.0.0-...-2ef2c73 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Heartbeat    EventType = "heartbeat"
	Registration           = "registration"
	EventRound             = "round"
	EventShot              = "shot"
)

Variables

View Source
var (
	ErrGameNotStarted            = fmt.Errorf("game not gameStarted yet")
	ErrGameAlreadyStarted        = fmt.Errorf("game already started")
	ErrInvalidPayload            = fmt.Errorf("invalid payload")
	ErrGameFinished              = fmt.Errorf("game is over")
	ErrInvalidPlayerRegistration = fmt.Errorf("invalid player registration event")
)

Various error messages

Functions

This section is empty.

Types

type Event

type Event struct {
	Type EventType       `json:"type"`
	Data json.RawMessage `json:"data,omitempty"`
}

func NewEvent

func NewEvent(eventType EventType, data interface{}) (*Event, error)

type EventType

type EventType string

type Game

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

func NewGame

func NewGame(cfg *domain.MasterConfig) *Game

func (*Game) EmitEvent

func (gs *Game) EmitEvent() (*Event, error)

EmitEvent generates an event based on the current game state.

func (*Game) HandleEvent

func (gs *Game) HandleEvent(event *Event) error

HandleEvent processes incoming events and updates the game state accordingly.

Jump to

Keyboard shortcuts

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