game

package
v0.0.0-...-e36e409 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Games = map[string]*Game{}

Functions

func Register

func Register(game *Game)

Types

type BaseEvent

type BaseEvent struct {
	ResponseStream chan Response
	User           *model.User
	Room           *model.Room
}

func (*BaseEvent) GetResponse

func (e *BaseEvent) GetResponse() Response

func (*BaseEvent) GetRoom

func (e *BaseEvent) GetRoom() *model.Room

func (*BaseEvent) GetSeat

func (e *BaseEvent) GetSeat() int

func (*BaseEvent) GetUser

func (e *BaseEvent) GetUser() *model.User

func (*BaseEvent) PutResponse

func (e *BaseEvent) PutResponse(res Response)

func (*BaseEvent) SetRoom

func (e *BaseEvent) SetRoom(room *model.Room)

func (*BaseEvent) SetUser

func (e *BaseEvent) SetUser(user *model.User)

type Event

type Event interface {
	PutResponse(Response)
	GetResponse() Response
	SetUser(user *model.User)
	GetUser() *model.User
	SetRoom(room *model.Room)
	GetRoom() *model.Room
}

type Game

type Game struct {
	Id   string
	Name string

	// setup
	Player  Range
	Options []Option

	// play
	NewEvent func() Event
	OnEvent  func(Event) Response
}

func FindGame

func FindGame(id string) (*Game, error)

type NewGameEvent

type NewGameEvent struct {
	BaseEvent
}

type Option

type Option struct {
	Id   string
	Name string
	Type OptionType
	Data interface{}
}

type OptionType

type OptionType int

type Range

type Range struct {
	Min int
	Max int
}

func (Range) Contain

func (r Range) Contain(i int) bool

type Response

type Response interface {
}

Jump to

Keyboard shortcuts

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