domain

package
v0.0.0-...-28e8972 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const IDLength int = 7 // 3 runes 1 dash 3 runes

Variables

View Source
var (
	ErrGameOver             = errors.New("game already over")
	ErrUserAlreadySubmitted = errors.New("user already submitted")
)
View Source
var ErrInvalidID = errors.New("invalid ID")
View Source
var GAMES = NewGames()

Functions

This section is empty.

Types

type Game

type Game struct {
	ID       ID            `json:"id"`
	HostID   ID            `json:"host_id"`
	IsActive bool          `json:"is_active"`
	Players  map[ID]Player `json:"players"`
}

func NewGame

func NewGame(hostID ID) (*Game, error)

func UnmarshalGame

func UnmarshalGame(strGame string) (*Game, error)

func (*Game) End

func (g *Game) End() error

func (*Game) Get

func (g *Game) Get(playerID ID) (*Player, error)

func (*Game) HandleSubmission

func (g *Game) HandleSubmission(playerID ID, name string) error

func (*Game) IsHost

func (g *Game) IsHost(playerID ID) bool

func (*Game) Join

func (g *Game) Join(playerID ID) error

func (*Game) Marshal

func (g *Game) Marshal() (*string, error)

func (*Game) Next

func (g *Game) Next() (*string, bool)

func (*Game) Slog

func (g *Game) Slog() func()

func (*Game) Unseen

func (g *Game) Unseen() int

type Games

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

func NewGames

func NewGames() *Games

func (*Games) Exists

func (g *Games) Exists(id ID) bool

func (*Games) Get

func (g *Games) Get(id ID) (*Game, error)

func (*Games) New

func (g *Games) New(game *Game) error

func (*Games) Set

func (g *Games) Set(game *Game) error

func (*Games) Slog

func (g *Games) Slog() func()

type ID

type ID string

func NewID

func NewID() ID

func ParseID

func ParseID(s string) (*ID, error)

func (*ID) GobDecode

func (id *ID) GobDecode(data []byte) error

func (ID) GobEncode

func (id ID) GobEncode() ([]byte, error)

func (*ID) String

func (id *ID) String() string

type Player

type Player struct {
	ID            ID      `json:"id"`
	SubmittedName *string `json:"submitted_name"`
	Seen          bool    `json:"seen"`
}

Jump to

Keyboard shortcuts

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