entity

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: AGPL-3.0 Imports: 3 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// MaxPC is the maximum number of characters an account can have.
	MaxPC = 4
)

Variables

View Source
var (
	// ErrInvalidEntityType is raised when an entity doesn't respect the correct type.
	ErrInvalidEntityType = errors.New("invalid entity type")
)

Functions

This section is empty.

Types

type E

type E struct {
	ID       ulid.ID  `json:"id"`
	Type     Type     `json:"type"`
	Name     string   `json:"name"`
	HP       uint64   `json:"hp"`
	MP       uint64   `json:"mp"`
	Position Position `json:"position"`
}

E represents a dynamic entity.

func (E) Equal

func (e E) Equal(entity E) bool

Equal returns if both entities are equal.

func (*E) Move

func (e *E) Move(p geometry.Vec3)

Move moves entity to position p.

type Mapper

type Mapper interface {
	SetEntity(E, int64) error
	GetEntity(Subset) (E, error)
	DelEntity(Subset) error
}

Mapper is an interface for E object.

type PC

type PC E

PC alias an entity.

func (PC) Check

func (pc PC) Check() error

Check checks if pc fields are valid.

type PCLeft

type PCLeft int

PCLeft represents the number of character an account can still create.

type PCLeftMapper

type PCLeftMapper interface {
	SetPCLeft(PCLeft, ulid.ID) error
	GetPCLeft(PCLeftSubset) (PCLeft, error)
}

PCLeftMapper interfaces creation/retrieval of PCLeft.

type PCLeftSubset

type PCLeftSubset struct {
	AccountID ulid.ID
}

PCLeftSubset represents a subset of PCLeft per account.

type PCMapper

type PCMapper interface {
	SetPC(PC, ulid.ID) error
	GetPC(PCSubset) (PC, error)
	ListPC(PCSubset) ([]PC, error)
}

PCMapper is an interface to create a new PC.

type PCSubset

type PCSubset struct {
	ID        ulid.ID
	AccountID ulid.ID
}

PCSubset represents a subset of PC by account ID.

type Permission

type Permission struct {
	ID     ulid.ID
	Source string
	Target string
	Value  int
}

Permission represents a links between 2 objects (token/identities/etc.).

type PermissionMapper

type PermissionMapper interface {
	SetPermission(Permission) error
	GetPermission(PermissionSubset) (Permission, error)
	ListPermission(PermissionSubset) ([]Permission, error)
	DelPermission(PermissionSubset) error
}

PermissionMapper defines Permission operations.

type PermissionSubset

type PermissionSubset struct {
	Source string
	Target string
}

PermissionSubset is the subset to retrieve a Permission.

type Position

type Position struct {
	Coord    geometry.Vec3
	SectorID ulid.ID
}

Position represents an entity position in world.

type Subset

type Subset struct {
	ID     ulid.ID
	MaxTS  int64
	Cursor uint64
	Count  int64
}

Subset is a subset to retrieve one entity.

type Template

type Template E

Template alias an entity. It represents semi static data. When creating PC/Entities, those templates are used.

type TemplateMapper

type TemplateMapper interface {
	SetEntityTemplate(Template) error
	GetEntityTemplate(TemplateSubset) (Template, error)
	ListEntityTemplate() ([]Template, error)
}

TemplateMapper is an interface for Template object.

type TemplateSubset

type TemplateSubset struct {
	Type Type
}

TemplateSubset is a subset to retrieve one template.

type Type

type Type = ulid.ID

Type represents the type of an entity.

Jump to

Keyboard shortcuts

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