model

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateLobby   = "lobby"
	StateRunning = "running"

	RoleHost   = "host"
	RolePlayer = "player"
)

Variables

View Source
var EmptyGameMap = make(GameMap)

Functions

func IsSupportedRole

func IsSupportedRole(s string) bool

func IsSupportedState

func IsSupportedState(s string) bool

Types

type Game

type Game struct {
	Id        string      `json:"id"`
	Type      string      `json:"type"`
	Players   []*Player   `json:"players"`
	State     string      `json:"state"`
	CreatedAt int64       `json:"createdAt"`
	UpdatedAt int64       `json:"updatedAt"`
	GameData  interface{} `json:"gameData"`
}

func (*Game) GetPlayer

func (g *Game) GetPlayer(pid string) *Player

type GameMap

type GameMap map[string]*Game

func (GameMap) AsSlice

func (g GameMap) AsSlice() []*Game

type Player

type Player struct {
	Id   string `json:"id"`
	Name string `json:"name"`
	Role string `json:"role"`
}

type UpdateStateRequest

type UpdateStateRequest struct {
	NewState string `json:"state"`
}

Jump to

Keyboard shortcuts

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