game

package
v0.0.0-...-332bf77 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Avatar

type Avatar struct {
	ID        string
	User      *entities.User
	Character *characters.Character
}

Avatar ... default active entity that moves in the world Avatars can be either controlled by Players/Users or be attached/belong to bots Once a user is logged in he automatically gets attached his last used aavatar

func NewAvatar

func NewAvatar() *Avatar

NewAvatar ... creates and returns a new room instance

type Game

type Game struct {

	// access to repository data
	Facade service.Facade

	SystemUser *entities.User

	OnUserJoined chan *m.UserJoined
	OnUserQuit   chan *m.UserQuit

	Receivers []Receiver

	CommandProcessor *c.CommandProcessor
	RoomProcessor    *c.RoomProcessor

	Avatars map[string]*Avatar
	// contains filtered or unexported fields
}

Game ... contains live game state

func New

func New(facade service.Facade) *Game

New creates a new game instance

func (*Game) GetFacade

func (g *Game) GetFacade() service.Facade

GetFacade ...

func (*Game) OnMessageReceived

func (g *Game) OnMessageReceived() chan interface{}

OnMessageReceived returns onMessageReceived channel

func (*Game) Run

func (g *Game) Run()

Run main game loop

func (*Game) SendMessage

func (g *Game) SendMessage() chan interface{}

SendMessage ...

func (*Game) Unsubscribe

func (g *Game) Unsubscribe(receiver *Receiver)

Unsubscribe ...

type Receiver

type Receiver interface {
	OnMessage(message interface{})
}

Receiver ... rec

type State

type State interface {
	Get(key string) (interface{}, bool)
	Set(key string, value interface{})
}

State ...

func GetState

func GetState() State

GetState ... return global MUD state cache can only contained cached states up to 60 minutes Should not be used for permament persistence

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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