Documentation ¶
Overview ¶
Package game provides interfaces for the source, compiler, and runtime packages, severing circular dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IList ¶
type IList interface { // Len returns the number of values in the list. Len() int // Get returns the value of the nth values in the list. Get(int) IValue // Contains returns true if the passed parameter exists in the list. // The parameter can be an IValue, IObject, number, text. Contains(interface{}) bool // AppendNum adds the passed number to the end of the list. AppendNum(float64) // AppendText adds the passed string to the end of the list. AppendText(string) // AppendObject adds the passed object to the end of the list. AppendObject(IObject) // Pop removes the last value from the list. Pop() IValue // Reset the list by completely emptying it. Reset() }
IValue provides access to an object list
type IObject ¶
type IObject interface { Id() ident.Id Exists() bool // FIX: added for obj.Object() tests, alternatives? // FromClass returns true if the object was derived from the passed plural named class. // FIX: seems to programmery, alternatives? FromClass(string) bool // Parent returns the spatial parent, enclosure, of an object. // by default, there is no such object, the standard rules, etc. define their own thing. ParentRelation() (IObject, string) Is(string) bool IsNow(string) Equals(IObject) bool // Get returns the named property. Get(string) IValue // List returns the named list. List(string) IList // Go run an action defined on this object. Go(action string, withTargetAndContext ...IObject) IPromise // FIX: this should probably just be an action. // Go("say", ...) Says(string) // deprecated: prefer Get() Num(string) float64 SetNum(string, float64) Object(string) IObject ObjectList(string) []IObject Set(string, IObject) Text(string) string SetText(string, string) }
IObject might have a few implementations: * valid objects * invalid objects while debugging which panics or errors * invalid objects during play which eat all errors * testing which logs all calls
type IPromise ¶
type IPromise interface {
Then(Callback)
}
IPromise doesnt currently provide a standard promise interface No actual chaining
type IValue ¶
type IValue interface { Num() float64 SetNum(float64) Object() IObject SetObject(IObject) Text() string SetText(string) State() ident.Id SetState(ident.Id) }
IValue provides access to an object property
type Play ¶
type Play interface { // The function retrieves a script declared instance. The(noun string) IObject // Our alias for The. Our(noun string) IObject // A(n) alias for The. A(noun string) IObject // Say friendly narrative print. Say(text ...string) // Log a quiet print. Log(text ...interface{}) // List one or more objects by class name. // FUTURE: replace class by an index? // ALT: broadcast an event to an optionally query/filtered set of objects. Query(class string, exact bool) IQuery // StopHere. // FIX: move into the event object, possible via callback parameter injection StopHere() // Go queue the passed runtime phrases for future execution. Go(RuntimePhrase, ...RuntimePhrase) IPromise // Random returns a number ranging from 0 to n, not including n. Random(n int) int }
Play provides the runtime with scripted callbacks.
type RuntimePhrase ¶
type RuntimePhrase interface {
Execute(Play)
}
RuntimePhrases are the workhorse of named actions. unlike named actions, they allow for typed parameters, and they dont raise events. in the future, it might be nice to associate a phrase with every action, they point towards user defined functions in some sort of user interface with slots which map to an "action class" -- a presentation for an action.