object

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDefinitionId

func BuildDefinitionId(zoneId string, definition string) string

func CategoriesToString

func CategoriesToString(cats []Category) string

Types

type Category

type Category int32
const (
	None Category = iota
	Weapon
	Wand
	Staff
	Treasure
	Armor
	Food
	Other
)

func IntsToCategories

func IntsToCategories(rawcats []int32) (result []Category)

func StringToCategory

func StringToCategory(categoryName string) (Category, error)

func (Category) String

func (i Category) String() string

type CategorySet

type CategorySet map[Category]bool

func (CategorySet) Add

func (cs CategorySet) Add(c Category)

func (CategorySet) Contains

func (cs CategorySet) Contains(c Category) bool

func (CategorySet) ToInt32List

func (cs CategorySet) ToInt32List() (result []int32)

type Definition

type Definition struct {
	Aliases             []string
	Categories          CategorySet
	Name                string
	ShortDescription    string // description of the object when being used: "a long, green stick" -> "The Beastly Fido picks up the long, green stick."
	DescriptionOnGround string // description of the object when lying on the ground: "A shiny sword is lying here."
	ZoneId              string
	WearLocation        slot.Location
	Behaviors           behavior.BehaviorSet
	// contains filtered or unexported fields
}

Definition of what it means to be an "object" the "platonic form" of an object, if you will.

There is a definition of the type "ShinySword" which defines the properties of what it means to be a ShinySword. An actual ShinySword lying around is an Instance.

func NewDefinition

func NewDefinition(definitionId string, name string, zoneId string, category Category, aliases []string, shortDescription string, descriptionOnGround string, wearLocation slot.Location) *Definition

func (*Definition) AddCategory

func (d *Definition) AddCategory(cat Category)

func (*Definition) CanEquipWeapon

func (d *Definition) CanEquipWeapon() bool

func (*Definition) CanWear

func (d *Definition) CanWear() bool

func (*Definition) HasAlias

func (d *Definition) HasAlias(target string) bool

func (*Definition) Id

func (d *Definition) Id() string

func (*Definition) Identifier

func (d *Definition) Identifier() string

return only the 'id' part of the Definition

type Instance

type Instance struct {
	InstanceId uuid.UUID
	Definition *Definition
}

The Instances of the Definitions in the world around you. That ShinySword in your hand has certain properties, some of which were inherited by what it means to be a ShinySword (Definition) and others which have happened to that particular instance (soul-bound to you, made invisible, with some damage to the hilt).

func NewInstance

func NewInstance(defn *Definition) *Instance

func (*Instance) CanEquipWeapon

func (i *Instance) CanEquipWeapon() bool

func (*Instance) Id

func (i *Instance) Id() string

func (*Instance) IsGettable

func (i *Instance) IsGettable() bool

type InstanceNotFoundError

type InstanceNotFoundError struct {
	Id string
}

func (*InstanceNotFoundError) Error

func (e *InstanceNotFoundError) Error() string

type InstanceNotWeaponError

type InstanceNotWeaponError struct {
	Id string
}

func (*InstanceNotWeaponError) Error

func (e *InstanceNotWeaponError) Error() string

type Slots

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

func NewSlots

func NewSlots() *Slots

func (*Slots) Get

func (slots *Slots) Get(s slot.Location) *Instance

func (*Slots) GetAll

func (slots *Slots) GetAll() map[slot.Location]*Instance

func (*Slots) IsItemInUse

func (slots *Slots) IsItemInUse(obj *Instance) bool

func (*Slots) IsSlotInUse

func (slots *Slots) IsSlotInUse(s slot.Location) (result bool)

func (*Slots) Set

func (slots *Slots) Set(s slot.Location, obj *Instance)

Jump to

Keyboard shortcuts

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