app

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

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassResource

func ClassResource(mdl meta.Model) resource.IResource

func EmptyLines

func EmptyLines(lines []string) bool

FXIXI some code -- like report the view -- prettifies the output by printing blank lines (ugh)

func NewObjectRef

func NewObjectRef(gobj meta.Instance) *resource.Object

func ObjectResource

func ObjectResource(mdl meta.Model, clsId ident.Id) resource.IResource

func ParserResource

func ParserResource(mdl meta.Model) resource.IResource

func SerializeObject

func SerializeObject(gobj meta.Instance) *resource.Object

SerializeObject to the passed resource. NOTE: unlike, jsonapi/rest we omit relationships and arrays.

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 (out *CommandOutput) BeginEvent(tgt, ctx meta.Instance, _ E.PathList, msg *E.Message) api.IEndEvent

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) NumChange

func (out *CommandOutput) NumChange(gobj meta.Instance, prop ident.Id, prev, next float64)

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 (out *CommandOutput) StateChange(gobj meta.Instance, prop ident.Id, prev, next ident.Id)

func (*CommandOutput) TextChange

func (out *CommandOutput) TextChange(gobj meta.Instance, prop ident.Id, prev, next string)

type Dict

type Dict map[string]interface{}

json-like serialization

type EventBlock

type EventBlock struct {
	Evt    string           `json:"evt,omitempty"`
	Tgt    *resource.Object `json:"tgt,omitempty"`
	Ctx    *resource.Object `json:"ctx,omitempty"`
	Data   interface{}      `json:"data,omitempty"`
	Events []*EventBlock    `json:"events,omitempty"`
}

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) Post

func (s *PartialSession) Post(reader io.Reader) (ret resource.Document, err error)

Post input to the game.

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

func (*RefSerializer) AddObject

func (o *RefSerializer) AddObject(gobj meta.Instance) (ret *resource.Object, okay bool)

type View

type View interface {
	View() ident.Id
	Viewer() ident.Id
	InView(meta.Instance) bool
	ChangedView(meta.Instance, ident.Id, meta.Instance) bool
	EnteredView(meta.Instance, ident.Id, meta.Instance) bool
}

Jump to

Keyboard shortcuts

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