meta

package
v0.0.0-...-9034458 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2016 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package meta provides interfaces for read / write interaction with models. a meta model holds all of the data for a single game. TODO: Evaluate if the enumeration interfaces ( NumEvent,GetEvent ) make sense -- a more generic "type" iteration might be better. TODO: Add interfaces for Querying, especially, but not only, for relations. ( probably key-object with property filter )

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	GetId() ident.Id
	// GetActionName returns the original name given by the scripter.
	GetActionName() string
	// GetEvent: raised by this action when the action occurs.
	GetEvent() Event
	// GetNouns: the classes for required by the action.
	GetNouns() Nouns
	//
	GetCallbacks() (Callbacks, bool)
}

type CallbackOptions

type CallbackOptions int
const (
	UseTargetOnly CallbackOptions = 1 << iota
	UseAfterQueue
)

func (CallbackOptions) UseAfterQueue

func (opt CallbackOptions) UseAfterQueue() bool

func (CallbackOptions) UseTargetOnly

func (opt CallbackOptions) UseTargetOnly() bool

type Callbacks

type Callbacks interface {
	NumCallback() int
	CallbackNum(int) ident.Id
}

type Class

type Class Prototype

type Event

type Event interface {
	GetId() ident.Id
	// GetEventName returns the original name given by the scripter.
	GetEventName() string
	// GetListeners returns the capture or bubbling callbacks associated with this event
	// if GetListeners returns false, Listeners should be set to NoListeners.
	GetListeners(capture bool) (Listeners, bool)
}

type Instance

type Instance Prototype

func FindFirstOf

func FindFirstOf(mdl Model, cls ident.Id) (ret Instance, okay bool)

type Listener

type Listener interface {
	// GetInstance can return Empty()
	GetInstance() ident.Id
	// GetClass always returns a valid class id.
	GetClass() ident.Id
	// GetCallback() returns a valid callback id.
	GetCallback() ident.Id
	//
	GetOptions() CallbackOptions
}

type Listeners

type Listeners interface {
	NumListener() int
	ListenerNum(int) Listener
}

type Model

type Model interface {
	NumAction() int
	ActionNum(int) Action
	GetAction(ident.Id) (Action, bool)

	NumEvent() int
	EventNum(int) Event
	GetEvent(ident.Id) (Event, bool)

	NumClass() int
	ClassNum(int) Class
	GetClass(ident.Id) (Class, bool)

	NumInstance() int
	InstanceNum(int) Instance
	GetInstance(ident.Id) (Instance, bool)

	NumRelation() int
	RelationNum(int) Relation
	GetRelation(ident.Id) (Relation, bool)

	NumParserAction() int
	ParserActionNum(int) ParserAction

	Pluralize(string) string
	AreCompatible(child, parent ident.Id) bool
	MatchNounName(string, func(ident.Id) bool) (tries int, err bool)
}

type NoListeners

type NoListeners [0]Listener

func (NoListeners) ListenerNum

func (no NoListeners) ListenerNum(i int) Listener

func (NoListeners) NumListener

func (no NoListeners) NumListener() int

type NounType

type NounType int
const (
	SourceNoun NounType = iota
	TargetNoun
	ContextNoun
)

type Nouns

type Nouns []ident.Id

a list of nouns

func (Nouns) Get

func (n Nouns) Get(t NounType) (ret ident.Id)

func (Nouns) GetNounCount

func (n Nouns) GetNounCount() int

type ParserAction

type ParserAction struct {
	Action   ident.Id
	Commands []string
}

NOTE: ParserActions aren't id'd, so they are represented as structs.

type Property

type Property interface {
	GetId() ident.Id
	GetName() string
	GetType() PropertyType
	//GetObjectType()?
	// or maybe IsCompatible(inst) bool
	GetValue() Value
	GetValues() Values
	// GetRelative returns false if there is no relation, for example: a pure array or object value.
	GetRelative() (Relative, bool)
}

type PropertyType

type PropertyType int
const (
	InvalidProperty PropertyType = iota
	NumProperty                  // float64
	TextProperty                 // string
	StateProperty                // string.Id
	ObjectProperty               // string.Id
	ArrayProperty   = 1 << 16
)

type Prototype

type Prototype interface {
	GetId() ident.Id

	// GetParentClass returns empty id for classes if no parent;
	// panics if no class can be found for an instance.
	GetParentClass() ident.Id
	GetOriginalName() string

	NumProperty() int
	PropertyNum(int) Property

	// FindProperty by its user given name.
	FindProperty(string) (Property, bool)

	// GetProperty by the property unique id.
	GetProperty(ident.Id) (Property, bool)

	// GetPropertyByChoice evalutes all properties to find an enumeration which can store the passed choice
	GetPropertyByChoice(ident.Id) (Property, bool)
}

Prototype holds properties; it supports both instance and class type things.

type Relation

type Relation interface {
	GetId() ident.Id
}

type Relative

type Relative struct {
	Relation ident.Id // Relation
	Relates  ident.Id // Relates class
	From     ident.Id // From property
}

type Value

type Value interface {
	GetNum() float64
	SetNum(float64) error

	GetText() string
	SetText(string) error

	GetState() ident.Id
	SetState(ident.Id) error

	GetObject() ident.Id
	SetObject(ident.Id) error

	SetRelation(ident.Id) error
}

get and set panic if the value is not of the requested type; set can return error when the value, when of the correct type, violates a property constraint

type Values

type Values interface {
	NumValue() int
	ValueNum(int) Value

	ClearValues() error
	AppendNum(float64) error
	AppendText(string) error
	AppendObject(ident.Id) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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