rooms

package
Version: v0.0.0-...-e366e6a Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoomExitTypeNormal    RoomExitType = "normal"
	RoomExitTypeDirection              = "direction"
	RoomExitTypeTeleport               = "teleport"
)

Variables

This section is empty.

Functions

func RoomToJSONString

func RoomToJSONString(room Room) string

RoomToJSONString ...

func RoomsToJSONString

func RoomsToJSONString(rooms Rooms) string

RoomsToJSONString ...

Types

type Action

type Action struct {
	Name        string                 `bson:"name,omitempty" json:"name,omitempty"`
	Description string                 `bson:"description,omitempty" json:"description,omitempty"`
	Response    string                 `bson:"response,omitempty" json:"response,omitempty"`
	Type        RoomActionType         `bson:"type,omitempty" json:"type,omitempty"`
	Params      map[string]interface{} `bson:"params,omitempty" json:"params"`
}

Action ... action that can be invoked by a player in thi room

type Actions

type Actions []Action

Actions type

type Characters

type Characters []string

Characters type

type Exit

type Exit struct {
	Name        string                 `bson:"name,omitempty" json:"name,omitempty"`
	Description string                 `bson:"description,omitempty" json:"description,omitempty"`
	Type        RoomExitType           `bson:"type,omitempty" json:"type,omitempty"`
	Hidden      bool                   `bson:"hidden,omitempty" json:"hidden,omitempty"`
	Target      string                 `bson:"target,omitempty" json:"target,omitempty"`
	Params      map[string]interface{} `bson:"params,omitempty" json:"params"`
}

Exit ... action that can be invoked by a player in thi room

type Exits

type Exits []Exit

Exits type

type Items

type Items []string

Items type

type Room

type Room struct {
	*entities.Entity `bson:",inline"`
	traits.LookAt    `bson:",inline"` // provides detail

	Name        string `bson:"name,omitempty" json:"name"`
	Description string `bson:"description,omitempty" json:"description"`
	//Detail      string `bson:"detail,omitempty" json:"detail"`
	RoomType string `bson:"roomType,omitempty" json:"roomType"`

	Area     string   `bson:"area,omitempty" json:"area"`
	AreaType string   `bson:"areaType,omitempty" json:"areaType"`
	Tags     []string `bson:"tags" json:"tags"`

	Actions    Actions    `bson:"actions" json:"actions"`
	Exits      Exits      `bson:"exits" json:"exits"`
	Characters Characters `bson:"characters" json:"characters"`
	Items      Items      `bson:"items" json:"items"`

	// can be optionally used for MUDs that want to be grid based or need stricter maps
	Coords *struct {
		X int32 `bson:"x" json:"x"`
		Y int32 `bson:"y" json:"y"`
		Z int32 `bson:"z" json:"z"`
	} `bson:"coords,omitempty" json:"coords,omitempty"`

	// additional non game critical meta information to enhance player experience on client
	Meta *struct {
		// supply a mood to the client (optional)
		Mood string `bson:"mood,omitempty" json:"mood,omitempty"`
		// supply a background image id to the client (optional)
		Background string `bson:"background,omitempty" json:"background,omitempty"`
	} `bson:"meta,omitempty" json:"meta,omitempty"`
}

Room data

func RoomFromJSONString

func RoomFromJSONString(input string) (*Room, error)

RoomFromJSONString ...

func (*Room) AddCharacter

func (room *Room) AddCharacter(character string) error

AddCharacter ,,,

func (*Room) GetExit

func (room *Room) GetExit(exit string) (Exit, bool)

GetExit ...

func (*Room) IsCharacterInRoom

func (room *Room) IsCharacterInRoom(character string) bool

IsCharacterInRoom ,,,

func (*Room) RemoveCharacter

func (room *Room) RemoveCharacter(character string) error

RemoveCharacter ,,,

type RoomActionType

type RoomActionType string

RoomActionType type

const (
	RoomActionTypeResponse     RoomActionType = "response"
	RoomActionTypeRoomResponse RoomActionType = "room_response"
	RoomActionTypeScript       RoomActionType = "script"
)

type RoomExitType

type RoomExitType string

RoomExitType type

type Rooms

type Rooms []*Room

Rooms type

func RoomsFromJSONString

func RoomsFromJSONString(input string) (Rooms, error)

RoomsFromJSONString ...

Jump to

Keyboard shortcuts

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