Documentation ¶
Overview ¶
Package app wraps the runtime in json input, output handlers. FIX: there are some references to "standard/framework", but this should be independent of all game rules.
Index ¶
- func ClassResource(mdl meta.Model) resource.IResource
- func EmptyLines(lines []string) bool
- func NewObjectRef(gobj meta.Instance) *resource.Object
- func ObjectResource(mdl meta.Model, clsId ident.Id) resource.IResource
- func ParserResource(mdl meta.Model) resource.IResource
- func SerializeObject(gobj meta.Instance) *resource.Object
- type CommandInput
- type CommandOutput
- func (out *CommandOutput) ActorSays(gobj meta.Instance, lines []string)
- func (out *CommandOutput) BeginEvent(tgt, ctx meta.Instance, _ E.PathList, msg *E.Message) api.IEndEvent
- func (out *CommandOutput) EndEvent()
- func (out *CommandOutput) FlushDocument(doc resource.DocumentBuilder)
- func (out *CommandOutput) FlushFrame()
- func (out *CommandOutput) Log(message string)
- func (out *CommandOutput) NumChange(gobj meta.Instance, prop ident.Id, prev, next float64)
- func (out *CommandOutput) ReferenceChange(gobj meta.Instance, prop, other ident.Id, prev, next meta.Instance)
- func (out *CommandOutput) ScriptSays(lines []string)
- func (out *CommandOutput) StateChange(gobj meta.Instance, prop ident.Id, prev, next ident.Id)
- func (out *CommandOutput) TextChange(gobj meta.Instance, prop ident.Id, prev, next string)
- type Dict
- type EventBlock
- type EventStream
- func (evs *EventStream) AddAction(act string, tgt *resource.Object, data interface{})
- func (evs *EventStream) CurrentEvent() (ret *EventBlock)
- func (evs *EventStream) Flush() (ret []*EventBlock)
- func (evs *EventStream) PopEvent()
- func (evs *EventStream) PushEvent(evt ident.Id, tgt, ctx meta.Instance, data interface{}) (ret *EventBlock)
- type ObjSerializer
- type PartialSession
- func (s *PartialSession) Find(name string) (ret resource.IResource, okay bool)
- func (s *PartialSession) FlushDocument(doc resource.DocumentBuilder) error
- func (s *PartialSession) Frame() int
- func (s *PartialSession) Post(reader io.Reader) (ret resource.Document, err error)
- func (s *PartialSession) Query() (ret resource.Document)
- type RefSerializer
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmptyLines ¶
FXIXI some code -- like report the view -- prettifies the output by printing blank lines (ugh)
Types ¶
type CommandInput ¶
type CommandInput struct { // Input accepts a raw input string from the user: when specified, the other fields are ignored. Input string `json:"in"` // Action accepts all known player actions: the source of player commands is always the player. Action string `json:"act"` // Target: the first noun of the action Target string `json:"tgt"` // Context: the second noun of the action. Context string `json:"ctx"` }
CommandInput defines the expected post data format from a client. ie. this aint REST.
func (*CommandInput) Nouns ¶
func (cmd *CommandInput) Nouns() []string
Nouns returns an array of target and context strings, skipping empty strings.
type CommandOutput ¶
type CommandOutput struct {
// contains filtered or unexported fields
}
CommandOutput records game state changes, gets sent to the player/client.
func NewCommandOutput ¶
func NewCommandOutput(id string, m meta.Model, view View) *CommandOutput
func (*CommandOutput) ActorSays ¶
func (out *CommandOutput) ActorSays(gobj meta.Instance, lines []string)
ActorSays adds a command for an actor's line of dialog.
func (*CommandOutput) BeginEvent ¶
func (*CommandOutput) EndEvent ¶
func (out *CommandOutput) EndEvent()
func (*CommandOutput) FlushDocument ¶
func (out *CommandOutput) FlushDocument(doc resource.DocumentBuilder)
FlushDocument containing all commands to the passed document builder.
func (*CommandOutput) FlushFrame ¶
func (out *CommandOutput) FlushFrame()
func (*CommandOutput) Log ¶
func (out *CommandOutput) Log(message string)
Log the passed message locally, doesn't generate a client command. FIX: a log interface -- perhaps as an anonymous member -- then we could have logf, etc.
func (*CommandOutput) ReferenceChange ¶
func (out *CommandOutput) ReferenceChange(gobj meta.Instance, prop, other ident.Id, prev, next meta.Instance)
currently sent on the "one" side of an object for any object value. ( ex. actor.whereabouts; not: room.contents. )
func (*CommandOutput) ScriptSays ¶
func (out *CommandOutput) ScriptSays(lines []string)
ScriptSays adds a command for passed script lines. ( The implementation actually consolidates consecutive script says into a single command. which gets written during flushPending() )
func (*CommandOutput) StateChange ¶
func (*CommandOutput) TextChange ¶
type EventBlock ¶
type EventStream ¶
type EventStream struct {
// contains filtered or unexported fields
}
EventStream provides hierarchical event output.
func NewEventStream ¶
func NewEventStream() *EventStream
func (*EventStream) AddAction ¶
func (evs *EventStream) AddAction(act string, tgt *resource.Object, data interface{})
AddAction adds an event without hierarchy
func (*EventStream) CurrentEvent ¶
func (evs *EventStream) CurrentEvent() (ret *EventBlock)
func (*EventStream) Flush ¶
func (evs *EventStream) Flush() (ret []*EventBlock)
func (*EventStream) PopEvent ¶
func (evs *EventStream) PopEvent()
func (*EventStream) PushEvent ¶
func (evs *EventStream) PushEvent(evt ident.Id, tgt, ctx meta.Instance, data interface{}) (ret *EventBlock)
type ObjSerializer ¶
type ObjSerializer struct {
// contains filtered or unexported fields
}
ObjSerializer generates object documents which include a turn counter. A document contains refs to out, and optionally out serialization of those referenced out.
func NewObjSerializer ¶
func NewObjSerializer(m meta.Model, out resource.ObjectList) *ObjSerializer
func (*ObjSerializer) Include ¶
func (o *ObjSerializer) Include(gobj meta.Instance)
Include serializes the object and its contents
func (*ObjSerializer) SerializeObject ¶
func (o *ObjSerializer) SerializeObject(gobj meta.Instance) (added bool)
SerializeObject adds the object to the wraped resource ( if it hasnt been done before )
type PartialSession ¶
type PartialSession struct {
// contains filtered or unexported fields
}
implements IResource for the session and Frame for the
func NewPartialSession ¶
func NewPartialSession(m meta.Model, calls api.LookupCallbacks, saver api.SaveLoad, out *CommandOutput) (ret *PartialSession, err error)
func (*PartialSession) Find ¶
func (s *PartialSession) Find(name string) (ret resource.IResource, okay bool)
Find the named game resource.
func (*PartialSession) FlushDocument ¶
func (s *PartialSession) FlushDocument(doc resource.DocumentBuilder) error
func (*PartialSession) Frame ¶
func (s *PartialSession) Frame() int
func (*PartialSession) Query ¶
func (s *PartialSession) Query() (ret resource.Document)
Query on the session itself always returns a blank document. See: post.
type RefSerializer ¶
type RefSerializer struct {
// contains filtered or unexported fields
}
func NewRefSerializer ¶
func NewRefSerializer(m meta.Model, out resource.ObjectsBuilder) *RefSerializer