internal

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugGet = false

Functions

func InstanceNotFound

func InstanceNotFound(name string) error

func MakeStringId

func MakeStringId(name string) ident.Id

func NullObject

func NullObject(name string) G.IObject

func NullObjectSource

func NullObjectSource(path PropertyPath, skip int) G.IObject

func RunPhrases

func RunPhrases(g *Game, d *RuntimeAction, phrases ...G.RuntimePhrase) (err error)

during execute, whatever event we are in -- we want to stay in, until the end of execute. basically we want to subvert the queue -- so all queued futures come into us

func StripStringId

func StripStringId(name string) ident.Id

Types

type ActionQueue

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

func NewActionQueue

func NewActionQueue(g *Game) *ActionQueue

func (ActionQueue) Empty

func (q ActionQueue) Empty() bool

func (ActionQueue) Enqueue

func (q ActionQueue) Enqueue(f Future)

func (ActionQueue) Pop

func (q ActionQueue) Pop() (ret Future)

func (*ActionQueue) ProcessActions

func (q *ActionQueue) ProcessActions(g *Game) (err error)

this craziness exists to help unwind the very deep callstacks the events create

func (ActionQueue) QueueFuture

func (q ActionQueue) QueueFuture(f Future)

type ChainedCallback

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

ChainedCallbacks implements Future for nested callbacks; created by PendingChain. ex. Then(func(g G.Play){ })

func (*ChainedCallback) Run

func (c *ChainedCallback) Run(g *Game) (err error)

func (*ChainedCallback) String

func (c *ChainedCallback) String() string

type ClassQuery

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

FUTURE: check mutation?

func (*ClassQuery) Advance

func (q *ClassQuery) Advance() (int, meta.Instance)

Advance does not modify q.

func (*ClassQuery) HasNext

func (q *ClassQuery) HasNext() bool

func (*ClassQuery) Next

func (q *ClassQuery) Next() (ret G.IObject)

type ClassTarget

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

Implements E.ITarget for classes. The objects and classes form a uniform chain of targets

func (ClassTarget) Class

func (ct ClassTarget) Class() ident.Id

func (ClassTarget) Id

func (ct ClassTarget) Id() ident.Id

func (ClassTarget) Parent

func (ct ClassTarget) Parent() (ret E.ITarget, okay bool)

Walk up the class hierarchy; when we reach the end, move to the next instance. (from E.ITarget)

func (ClassTarget) String

func (ct ClassTarget) String() string

func (ClassTarget) TargetDispatch

func (ct ClassTarget) TargetDispatch(evt E.IEvent) (err error)

Send an event to ct target. (from E.ITarget)

type Future

type Future interface {
	Run(g *Game) error
}

FUTURE: do we need to pass Game here? could we have a future queue ( and promises ) as a completely separate system?

type Game

type Game struct {
	Model meta.Model
	RuntimeCore
	Queue *ActionQueue
}

func NewGame

func NewGame(core RuntimeCore, m meta.Model) *Game

func (*Game) NewRuntimeAction

func (g *Game) NewRuntimeAction(action meta.Action, nouns ...ident.Id,
) (ret *RuntimeAction, err error,
)

NewRuntimeAction: captures an action and bunch of nouns. TODO: unwind this... possibly now merege this with the go bits....

func (*Game) ProcessActions

func (g *Game) ProcessActions() error

func (*Game) QueueAction

func (g *Game) QueueAction(data *RuntimeAction)

func (*Game) Random

func (g *Game) Random(exclusiveMax int) int

type GameCallback

type GameCallback struct {
	meta.Listener
	// contains filtered or unexported fields
}

GameCallback adapts model listeners to game events. ( by implementing E.IListen )

func (GameCallback) HandleEvent

func (cb GameCallback) HandleEvent(evt E.IEvent) (err error)

HandleEvent implements E.IListen.

type GameEventAdapter

type GameEventAdapter struct {
	*Game
	// contains filtered or unexported fields
}

GameEventAdapter implements game.Play.

func NewGameAdapter

func NewGameAdapter(game *Game) *GameEventAdapter

NewGameAdapter gives the passed game the IPlay interface Public for testing.

func (*GameEventAdapter) A

func (ga *GameEventAdapter) A(name string) G.IObject

func (*GameEventAdapter) GetObject

func (ga *GameEventAdapter) GetObject(name string) (ret G.IObject)

could make a map that implements IObject? could use special keys for $name, $fullname, $game, etc. FUTURE: use dependency injection instead

func (*GameEventAdapter) Go

func (ga *GameEventAdapter) Go(phrase G.RuntimePhrase, phrases ...G.RuntimePhrase) (ret G.IPromise)

g.Go( Move("the player").To("the pit of disrepair") )

func (*GameEventAdapter) Log

func (ga *GameEventAdapter) Log(texts ...interface{})

func (*GameEventAdapter) NewGameObject

func (ga *GameEventAdapter) NewGameObject(inst meta.Instance) (ret G.IObject)

func (*GameEventAdapter) NewGameObjectFromId

func (ga *GameEventAdapter) NewGameObjectFromId(id ident.Id) (ret G.IObject)

NewGameObject gives the passed game object the IObject interface. Public for testing.

func (*GameEventAdapter) Our

func (ga *GameEventAdapter) Our(name string) G.IObject

func (*GameEventAdapter) Query

func (ga *GameEventAdapter) Query(class string, exact bool) (ret G.IQuery)

func (*GameEventAdapter) Say

func (ga *GameEventAdapter) Say(texts ...string)

func (*GameEventAdapter) StopHere

func (ga *GameEventAdapter) StopHere()

func (*GameEventAdapter) The

func (ga *GameEventAdapter) The(name string) G.IObject

type GameListeners

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

implements EventListeners

func NewGameListeners

func NewGameListeners(game *Game, evt E.IEvent, target ident.Id, ls meta.Listeners) GameListeners

filter listeners to the events appropriate for this target

func (GameListeners) ListenerNum

func (gl GameListeners) ListenerNum(i int) E.IListen

func (GameListeners) NumListener

func (gl GameListeners) NumListener() int

type GameObject

type GameObject struct {
	*GameEventAdapter // for console, Go(), and relations
	// contains filtered or unexported fields
}

GameObject wraps Instances for user script s. WARNING: for users to test object equality, the GameObject must be comparable; it can't implement the interface as a pointer, and it cant have any cached values.

func (*GameObject) Equals

func (oa *GameObject) Equals(r G.IObject) bool

func (*GameObject) Exists

func (oa *GameObject) Exists() bool

Exists always returns true for GameObject; see also NullObject which always returns false.

func (*GameObject) FromClass

func (oa *GameObject) FromClass(class string) (okay bool)

FromClass returns true when the object is compatible with ( based on ) the named class. ( parent or other ancestor )

func (*GameObject) Get

func (oa *GameObject) Get(prop string) G.IValue

func (*GameObject) Go

func (oa *GameObject) Go(run string, objects ...G.IObject) (ret G.IPromise)

Go sends all the events associated with the named action, and runs the default action if appropriate. ex. g.The("player").Go("show to", "the alien boy", "the ring")

func (*GameObject) Id

func (oa *GameObject) Id() ident.Id

Id uniquely identifies the object.

func (*GameObject) Is

func (oa *GameObject) Is(state string) (ret bool)

Is this object in the passed state?

func (*GameObject) IsNow

func (oa *GameObject) IsNow(state string)

IsNow changes the state of an object.

func (*GameObject) List

func (oa *GameObject) List(prop string) (ret G.IList)

func (*GameObject) Num

func (oa *GameObject) Num(prop string) (ret float64)

Num value of the named property.

func (*GameObject) Object

func (oa *GameObject) Object(prop string) (ret G.IObject)

Object returns a related object.

func (*GameObject) ObjectList

func (oa *GameObject) ObjectList(prop string) (ret []G.IObject)

ObjectList returns a list of related objects.

func (*GameObject) ParentRelation

func (oa *GameObject) ParentRelation() (ret G.IObject, rel string)

func (*GameObject) Says

func (oa *GameObject) Says(text string)

Says provides this object with a voice.

func (*GameObject) Set

func (oa *GameObject) Set(prop string, object G.IObject)

Set changes an object relationship.

func (*GameObject) SetNum

func (oa *GameObject) SetNum(prop string, value float64)

SetNum changes the value of an existing number property.

func (*GameObject) SetText

func (oa *GameObject) SetText(prop string, text string)

SetText changes the value of an existing text property.

func (*GameObject) String

func (oa *GameObject) String() string

String helps debugging.

func (*GameObject) Text

func (oa *GameObject) Text(prop string) (ret string)

Text value of the named property ( expanding any templated text. ) ( interestingly, inform seems to error when trying to store or manipulate templated text. )

type NilPromise

type NilPromise struct{}

func (NilPromise) Then

func (NilPromise) Then(G.Callback)

type ObjectTarget

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

ObjectTarget implements event.ITarget for Instances. The standard rules implement a hierarchy of objects based on containment; for instance: carried object => carrier=> container/supporter of the carrier => room of the contaniner.

func NewObjectTarget

func NewObjectTarget(g *Game, o meta.Instance) ObjectTarget

func (ObjectTarget) Class

func (ot ObjectTarget) Class() ident.Id

func (ObjectTarget) Id

func (ot ObjectTarget) Id() ident.Id

func (ObjectTarget) Parent

func (ot ObjectTarget) Parent() (ret E.ITarget, ok bool)

Parent walks up the the (externally defined) containment hierarchy (from event.ITarget.)

func (ObjectTarget) String

func (ot ObjectTarget) String() string

func (ObjectTarget) TargetDispatch

func (ot ObjectTarget) TargetDispatch(evt E.IEvent) (err error)

Dispatch an event to an object (from event.ITarget.)

type PendingChain

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

PendingChain implements runtime.IChain, it fills out the chained callback if the user links one in.

func NewPendingChain

func NewPendingChain(src *GameEventAdapter, _ Future) PendingChain

func (PendingChain) Then

func (c PendingChain) Then(cb G.Callback)

type PropertyPath

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

PropertyPath is used for error logging to track the full path to some property ex. bob/inventory/items/4/name FIX FIX FIX: the storing of strings has overhead, and is a bit ambiguous. might be interesting if instead, each element ( object, gameList, gameValue ) supported an interface for debug printing the chain ( since thats what we and nothing more ) in most cases they could keep a source access parent pointer of the same interface. ( note that's the accessed parent starting from the script callback, not some absolute parent -- ie. the name of an item could come via some class query ( all swords ) or bob's inventory

func NewPath

func NewPath(id ident.Id) PropertyPath

func RawPath

func RawPath(s string) PropertyPath

func (PropertyPath) Add

func (p PropertyPath) Add(s string) PropertyPath

func (PropertyPath) Index

func (p PropertyPath) Index(i int) PropertyPath

func (PropertyPath) InvalidIndex

func (p PropertyPath) InvalidIndex(i int) PropertyPath

func (PropertyPath) String

func (p PropertyPath) String() string

type QueuedAction

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

QueuedAction implements Future for named actions. ex. g.The("player").Go("jump")

func (*QueuedAction) Run

func (a *QueuedAction) Run(g *Game) (err error)

g.The("player").Go("hack", "the nice code").Then(trailing actions...)

type QueuedCallback

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

each action can have a chain of default actions

func (QueuedCallback) String

func (q QueuedCallback) String() string

FIX: change callbacks to include a source file/line location

type QueuedPhrase

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

QueuedAction implements Future for runtime phrases. ex. g.Go(Jump("player")

func (*QueuedPhrase) Run

func (c *QueuedPhrase) Run(g *Game) (err error)

func (*QueuedPhrase) String

func (c *QueuedPhrase) String() string

type QueuedPhrases

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

QueuedPhrases implements Future for a set of phrases. One aspect not yet? modeled are long running actions. Currently, there would be no difference, therefore, between chaining on QueuedPhrases and chaining on the last element of QueuedPhrases

func (*QueuedPhrases) Run

func (c *QueuedPhrases) Run(g *Game) (err error)

func (*QueuedPhrases) String

func (c *QueuedPhrases) String() string

type RuntimeAction

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

RuntimeAction contains data for event handlers and actions.

func NewRuntimeAction

func NewRuntimeAction(act meta.Action, objects []meta.Instance) *RuntimeAction

func (*RuntimeAction) Cancelled

func (act *RuntimeAction) Cancelled() bool

func (*RuntimeAction) GetContext

func (act *RuntimeAction) GetContext() (ret meta.Instance)

func (*RuntimeAction) GetTarget

func (act *RuntimeAction) GetTarget() (ret meta.Instance)

type RuntimeCore

type RuntimeCore struct {
	api.LookupCallbacks
	api.LookupParents
	api.Log
	api.SaveLoad
	//
	Frame  api.EventFrame
	Output api.Output
	Rand   *rand.Rand // FIX: an interface part of config
}

Jump to

Keyboard shortcuts

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