spaces

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateMobile

type CreateMobile struct {
	MobileDefinitionId string // what type of mobile
	RoomId             string // where does the mobile go?
	InstanceMax        int    // how many are allowed to be walking around the zone?

}

Command: Create a Mobile

func (CreateMobile) String

func (cmd CreateMobile) String() string

type CreateObject

type CreateObject struct {
	ObjectDefinitionId string // what type of object
	RoomId             string // where does the object go?
	InstanceMax        int    // how many are allowed to be lying around the zone?
}

Command: Create an Object

func (CreateObject) String

func (cmd CreateObject) String() string

type MobileRoomMap

type MobileRoomMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMobileRoomMap

func NewMobileRoomMap() *MobileRoomMap

func (*MobileRoomMap) Add

func (m *MobileRoomMap) Add(mob *mobile.Instance, r *Room)

func (*MobileRoomMap) GetAllMobiles

func (m *MobileRoomMap) GetAllMobiles() (mobs []*mobile.Instance)

func (*MobileRoomMap) GetMobileDefinitionCount

func (m *MobileRoomMap) GetMobileDefinitionCount(mobileDefinitionId string) (count int)

func (*MobileRoomMap) GetRoomForMobile

func (m *MobileRoomMap) GetRoomForMobile(mob *mobile.Instance) *Room

func (*MobileRoomMap) Remove

func (m *MobileRoomMap) Remove(mob *mobile.Instance)

type Room

type Room struct {
	Id          string
	Name        string
	Description string
	Zone        *Zone
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(zone *Zone, id string, name string, description string) *Room

Create a new Room reference

func NewTestRoom

func NewTestRoom(name string) *Room

Build a strip down version of a Room, for testing

func (*Room) AddInventory

func (r *Room) AddInventory(inst *object.Instance) error

func (*Room) AddMobile

func (r *Room) AddMobile(inst *mobile.Instance) error

func (*Room) AddPlayer

func (r *Room) AddPlayer(p player.Player)

Add a player to a room. Don't send notifications.

func (*Room) CreateRoomDescription

func (r *Room) CreateRoomDescription(exclude player.Player) *message.RoomDescription

Describe this room.

func (*Room) FindInventory

func (r *Room) FindInventory(findMode message.FindMode, index string, target string) (inst *object.Instance, exists bool)

Attempt to find an inventory object in this room which matches the terms given. Search the object name and aliases.

func (*Room) Get

func (r *Room) Get(dir direction.Direction) (dest *Room)

Get the exit for this direction. Will return nil if there isn't a valid exit that way. TODO what about exits that are locked or closed?

func (*Room) GetAllInventory

func (r *Room) GetAllInventory() []*object.Instance

func (*Room) GetExitString

func (r *Room) GetExitString() string

Get all the valid exits from this room. Note the ordering of the letters in the exit string is important! For example, with exits north, south, and up, this returns "nsu" TODO: exits can be locked and/or closed, this doesn't handle that.

func (*Room) GetInventoryByInstanceId

func (r *Room) GetInventoryByInstanceId(instanceId uuid.UUID) (inst *object.Instance, exists bool)

func (*Room) GetInventoryByName

func (r *Room) GetInventoryByName(name string) (inst *object.Instance, exists bool)

Find an object.Instance that matches this name

func (*Room) GetPlayers

func (r *Room) GetPlayers() []player.Player

func (*Room) GetRoomExits

func (r *Room) GetRoomExits(limitToZone bool) []RoomExit

Return the (direction, room) pairs for the exits from this room. Uses the direction.Direction ordering. Does not take locks, doors, closures, etc. into account.

func (*Room) HasExit

func (r *Room) HasExit(dir direction.Direction) bool

Is there a valid exit in this direction in this room? TODO what about exits that are locked or closed?

func (*Room) MobileEnters

func (r *Room) MobileEnters(mob *mobile.Instance)

func (*Room) MobileLeaves

func (r *Room) MobileLeaves(mob *mobile.Instance, dir direction.Direction)

func (*Room) PickRandomDirection

func (r *Room) PickRandomDirection(limitToZone bool) direction.Direction

Of the directions available for travel (could be locked, closed...) pick one of them. If there aren't any, return none.

func (*Room) PlayerEnters

func (r *Room) PlayerEnters(p player.Player)

Player enters a room. Tells other room residents about it.

func (*Room) PlayerLeaves

func (r *Room) PlayerLeaves(p player.Player, dir direction.Direction)

Player leaves a room. Tells other room residents about it.

func (*Room) RemoveInventory

func (r *Room) RemoveInventory(inst *object.Instance) error

func (*Room) RemoveMobile

func (r *Room) RemoveMobile(inst *mobile.Instance)

func (*Room) RemovePlayer

func (r *Room) RemovePlayer(p player.Player)

func (*Room) Send

func (r *Room) Send(msg interface{})

Send to every player in the room.

func (*Room) SendExcept

func (r *Room) SendExcept(exception player.Player, msg interface{})

Send to all players in a room, except for one of them.

func (*Room) Set

func (r *Room) Set(dir direction.Direction, destRoom *Room)

func (Room) String

func (r Room) String() string

type RoomExit

type RoomExit struct {
	Direction direction.Direction
	Room      *Room
}

A direction is an exit to another room.

type RoomInventory

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

func NewRoomInventory

func NewRoomInventory() *RoomInventory

func (*RoomInventory) Add

func (ri *RoomInventory) Add(inst *object.Instance) (err error)

func (*RoomInventory) Find

func (ri *RoomInventory) Find(findMode message.FindMode, index string, target string) (inst *object.Instance, exists bool)

Find an instance in this inventory with a name or alias matching the terms given.

func (*RoomInventory) GetAll

func (ri *RoomInventory) GetAll() (result []*object.Instance)

func (*RoomInventory) GetByInstanceId

func (ri *RoomInventory) GetByInstanceId(id uuid.UUID) (inst *object.Instance, exists bool)

func (*RoomInventory) GetByName

func (ri *RoomInventory) GetByName(name string) (inst *object.Instance, exists bool)

Find the instance with this name in the room note this needs to become much more sophisticated... Note that there is much left undone by this implementation (stacks of items, aliases...)

func (*RoomInventory) GetByNameOrAlias

func (ri *RoomInventory) GetByNameOrAlias(target string) (inst *object.Instance, exists bool)

func (*RoomInventory) Remove

func (ri *RoomInventory) Remove(inst *object.Instance) (err error)

type Zone

type Zone struct {
	Id                string
	Rooms             map[string]*Room
	ObjectDefinitions map[string]*object.Definition // id (no zone) -> object.Definition
	MobileDefinitions map[string]*mobile.Definition // id -> mobile.Definition
	Name              string
	Commands          []ZoneCommand
	ResetMode         zonereset.Mode
	LastReset         time.Time
	Lifetime          time.Duration
}

func NewZone

func NewZone(id string, name string, resetMode zonereset.Mode, lifetime time.Duration) *Zone

func (*Zone) AddCommand

func (z *Zone) AddCommand(c ZoneCommand)

func (*Zone) AddMobileDefinition

func (z *Zone) AddMobileDefinition(mob *mobile.Definition)

func (*Zone) AddObjectDefinition

func (z *Zone) AddObjectDefinition(obj *object.Definition)

func (*Zone) AddRoom

func (z *Zone) AddRoom(r *Room)

func (*Zone) Reset

func (z *Zone) Reset(mobileRoomMap *MobileRoomMap) (errors []error)

func (*Zone) String

func (z *Zone) String() string

type ZoneCommand

type ZoneCommand interface {
}

Supertype for all Zone Commands

Jump to

Keyboard shortcuts

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