Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = fx.Provide(func(motd string, dbaccess *dba.DBAccess, repository dba.Repository) *Game {
game := GetInstance()
game.MOTD = motd
game.Repository = repository
return game
})
Module ... fx module export
Functions ¶
This section is empty.
Types ¶
type Avatar ¶
type Avatar struct { CurrentUser *users.User `json:"id,omitempty" bson:"-"` // contains filtered or unexported fields }
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 LoadAvatar ¶
LoadAvatar ... loads and returns the avatar
func (*Avatar) Description ¶
Description ... returns the description
func (*Avatar) SetCurrentRoomID ¶
SetCurrentRoomID ... returns the name
type AvatarJoinedRoom ¶
AvatarJoinedRoom ... asdd
type AvatarLeftRoom ¶
AvatarLeftRoom ... asdd
type CommandProcessor ¶
type CommandProcessor struct {
// contains filtered or unexported fields
}
CommandProcessor ... global user struct to control logins
func NewCommandProcessor ¶
func NewCommandProcessor() *CommandProcessor
NewCommandProcessor .. creates a new command processor
func (*CommandProcessor) Process ¶
func (commandProcessor *CommandProcessor) Process(game *Game, message *Message) bool
Process ...asd
func (*CommandProcessor) RegisterCommand ¶
func (commandProcessor *CommandProcessor) RegisterCommand(key string, command Command)
RegisterCommand ... register
type Game ¶
type Game struct { Repository dba.Repository MOTD string SystemUser *users.User // messages OnMessageReceived chan *Message OnUserJoined chan *UserJoined OnUserQuit chan *UserQuit OnAvatarJoinedRoom chan *AvatarJoinedRoom OnAvatarLeftRoom chan *AvatarLeftRoom Receivers []Receiver CommandProcessor *CommandProcessor Avatars map[string]*Avatar // contains filtered or unexported fields }
Game ... default entity to structure rooms This is the main class that controls the real-time game flow for tcp and websocket clients. this is the live world, all changes to it will be stored to the database. The game instance can be recreated/loaded from a World instance inside the database
func (*Game) CreateRoom ¶
CreateRoom ... processes every entity
type Room ¶
type Room struct { ID bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"` Title string `json:"title"` Description string `json:"description"` CreationDate time.Time `json:"creationDate,omitempty"` Avatars []*Avatar `json:"avatars"` }
Room ... default entity to structure rooms
type UserJoined ¶
UserJoined ... player joined event
func NewUserJoined ¶
func NewUserJoined(user *users.User) *UserJoined
NewUserJoined ... creates a new User Joined event
type UserQuit ¶
UserQuit ... player joined event
func NewUserQuit ¶
NewUserQuit ... creates a new User Joined event
type World ¶
type World struct { ID bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"` DateCreated time.Time `json:"dateCreated,omitempty"` Rooms []*Room `json:"rooms,omitempty"` Avatars []*Avatar `json:"avatars,omitempty"` StartingRoomID string `json:"startingRoomId,omitempty"` }
World ... default entity to structure rooms Everything regarding content and live/dynamic data such as items, avatars, room shall be managed from the World class - all generic game/message/command related things will reside in the game class
func (*World) GetStartingRoom ¶
GetStartingRoom ... returns the StartingRoom for this world