Documentation
¶
Index ¶
- type CreateMobile
- type CreateObject
- type MobileRoomMap
- func (m *MobileRoomMap) Add(mob *mobile.Instance, r *Room)
- func (m *MobileRoomMap) GetAllMobiles() (mobs []*mobile.Instance)
- func (m *MobileRoomMap) GetMobileDefinitionCount(mobileDefinitionId string) (count int)
- func (m *MobileRoomMap) GetRoomForMobile(mob *mobile.Instance) *Room
- func (m *MobileRoomMap) Remove(mob *mobile.Instance)
- type Room
- func (r *Room) AddInventory(inst *object.Instance) error
- func (r *Room) AddMobile(inst *mobile.Instance) error
- func (r *Room) AddPlayer(p player.Player)
- func (r *Room) CreateRoomDescription(exclude player.Player) *message.RoomDescription
- func (r *Room) FindInventory(findMode message.FindMode, index string, target string) (inst *object.Instance, exists bool)
- func (r *Room) Get(dir direction.Direction) (dest *Room)
- func (r *Room) GetAllInventory() []*object.Instance
- func (r *Room) GetExitString() string
- func (r *Room) GetInventoryByInstanceId(instanceId uuid.UUID) (inst *object.Instance, exists bool)
- func (r *Room) GetInventoryByName(name string) (inst *object.Instance, exists bool)
- func (r *Room) GetPlayers() []player.Player
- func (r *Room) GetRoomExits(limitToZone bool) []RoomExit
- func (r *Room) HasExit(dir direction.Direction) bool
- func (r *Room) MobileEnters(mob *mobile.Instance)
- func (r *Room) MobileLeaves(mob *mobile.Instance, dir direction.Direction)
- func (r *Room) PickRandomDirection(limitToZone bool) direction.Direction
- func (r *Room) PlayerEnters(p player.Player)
- func (r *Room) PlayerLeaves(p player.Player, dir direction.Direction)
- func (r *Room) RemoveInventory(inst *object.Instance) error
- func (r *Room) RemoveMobile(inst *mobile.Instance)
- func (r *Room) RemovePlayer(p player.Player)
- func (r *Room) Send(msg interface{})
- func (r *Room) SendExcept(exception player.Player, msg interface{})
- func (r *Room) Set(dir direction.Direction, destRoom *Room)
- func (r Room) String() string
- type RoomExit
- type RoomInventory
- func (ri *RoomInventory) Add(inst *object.Instance) (err error)
- func (ri *RoomInventory) Find(findMode message.FindMode, index string, target string) (inst *object.Instance, exists bool)
- func (ri *RoomInventory) GetAll() (result []*object.Instance)
- func (ri *RoomInventory) GetByInstanceId(id uuid.UUID) (inst *object.Instance, exists bool)
- func (ri *RoomInventory) GetByName(name string) (inst *object.Instance, exists bool)
- func (ri *RoomInventory) GetByNameOrAlias(target string) (inst *object.Instance, exists bool)
- func (ri *RoomInventory) Remove(inst *object.Instance) (err error)
- type Zone
- type ZoneCommand
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 ¶
func NewMobileRoomMap ¶
func NewMobileRoomMap() *MobileRoomMap
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 NewTestRoom ¶
Build a strip down version of a Room, for testing
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 ¶
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 (*Room) GetExitString ¶
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 (*Room) GetInventoryByName ¶
Find an object.Instance that matches this name
func (*Room) GetPlayers ¶
func (*Room) GetRoomExits ¶
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 ¶
Is there a valid exit in this direction in this room? TODO what about exits that are locked or closed?
func (*Room) MobileEnters ¶
func (*Room) MobileLeaves ¶
func (*Room) PickRandomDirection ¶
Of the directions available for travel (could be locked, closed...) pick one of them. If there aren't any, return none.
func (*Room) PlayerEnters ¶
Player enters a room. Tells other room residents about it.
func (*Room) PlayerLeaves ¶
Player leaves a room. Tells other room residents about it.
func (*Room) RemoveMobile ¶
func (*Room) RemovePlayer ¶
func (*Room) SendExcept ¶
Send to all players in a room, except for one of them.
type RoomInventory ¶
type RoomInventory struct {
// contains filtered or unexported fields
}
func NewRoomInventory ¶
func NewRoomInventory() *RoomInventory
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)
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 (*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) Reset ¶
func (z *Zone) Reset(mobileRoomMap *MobileRoomMap) (errors []error)