model

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

Documentation

Overview

Package Model provides a post-compiled representation of the scripts.

Index

Constants

View Source
const (
	NumProperty     PropertyType = "NumProperty"
	TextProperty                 = "TextProperty"
	PointerProperty              = "PointerProperty"
	EnumProperty                 = "EnumProperty"
)
View Source
const (
	OneToOne   RelationStyle = "OneToOne"
	OneToMany                = "OneToMany"
	ManyToOne                = "ManyToOne"
	ManyToMany               = "ManyToMany"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionModel

type ActionModel struct {
	Id             ident.Id   `json:"id"`
	Name           string     `json:"name"`    // Original Name
	EventId        ident.Id   `json:"event"`   // Related Event
	NounTypes      []ident.Id `json:"nouns"`   // Classes
	DefaultActions []ident.Id `json:"actions"` // Callbacks
}

func (ActionModel) String

func (a ActionModel) String() string

type Actions

type Actions map[ident.Id]*ActionModel

type Aliases

type Aliases map[string]RankedStringIds

Aliases maps names typed by the player to ids.

func (Aliases) Try

func (a Aliases) Try(name string, try func(ident.Id) bool) (tries int, okay bool)

Try the passed function for every noun matching the passed name. Exits if the passed function returns true; returns the number of tries.

type CallbackModel

type CallbackModel struct {
	File      string
	Line      int
	Iteration int
}

func (CallbackModel) String

func (m CallbackModel) String() (ret string)

type ClassModel

type ClassModel struct {
	Id         ident.Id        `json:"id"`
	Parents    []ident.Id      `json:"parents"`
	Plural     string          `json:"plural"`
	Singular   string          `json:"singular"`
	Properties []PropertyModel `json:"properties"`
}

func (ClassModel) FindProperty

func (cls ClassModel) FindProperty(name string) (ret *PropertyModel, okay bool)

func (ClassModel) GetProperty

func (cls ClassModel) GetProperty(id ident.Id) (ret *PropertyModel, okay bool)

FindProperty does not search parent classes.

func (ClassModel) Parent

func (cls ClassModel) Parent() (ret ident.Id)

func (ClassModel) String

func (cls ClassModel) String() string

type Classes

type Classes map[ident.Id]*ClassModel

type EnumModel

type EnumModel struct {
	Choices []ident.Id `json:"choices"`
}

An indexed set of values.

func (*EnumModel) Best

func (e *EnumModel) Best() (ret ident.Id)

func (*EnumModel) ChoiceToIndex

func (e *EnumModel) ChoiceToIndex(choice ident.Id) (ret int)

1 based

func (*EnumModel) IndexToChoice

func (e *EnumModel) IndexToChoice(idx int) (ret ident.Id)

type Enumerations

type Enumerations map[ident.Id]*EnumModel

type EventModel

type EventModel struct {
	Id      ident.Id            `json:"id"`
	Name    string              `json:"name"`
	Capture EventModelCallbacks `json:"capture,omitempty"`
	Bubble  EventModelCallbacks `json:"bubble,omitempty"`
}

func (EventModel) String

func (e EventModel) String() string

type EventModelCallbacks

type EventModelCallbacks []ListenerModel

type Events

type Events map[ident.Id]*EventModel

type InstanceModel

type InstanceModel struct {
	Id     ident.Id `json:"id"`
	Class  ident.Id `json:"type"`
	Name   string   `json:"name"`
	Values Values   `json:"values,omitempty"`
}

func (*InstanceModel) GetId

func (n *InstanceModel) GetId() ident.Id

func (*InstanceModel) GetOriginalName

func (n *InstanceModel) GetOriginalName() string

func (*InstanceModel) GetParentClass

func (n *InstanceModel) GetParentClass() ident.Id

func (*InstanceModel) String

func (n *InstanceModel) String() string

type Instances

type Instances map[ident.Id]*InstanceModel

type ListenerModel

type ListenerModel struct {
	Instance,
	Class,
	Callback ident.Id // Game callback triggered by cb listener.
	Options ListenerOptions
}

For scenes we dont want to bake these into the class or instances; its cheating, but for now using the same structure for class and instance. NOTE: Instance can be empty if its a class based listener. For the sake of sharing: Even though we listen to events, we point to the action.

func (ListenerModel) GetId

func (cb ListenerModel) GetId() (ret ident.Id)

Return name of instance ( or class ).

func (ListenerModel) UseAfterQueue

func (cb ListenerModel) UseAfterQueue() bool

UseAfterQueue if the listener wants to trigger after a successful event cycle.

func (ListenerModel) UseTargetOnly

func (cb ListenerModel) UseTargetOnly() bool

UseTargetOnly if the listener wants callback only when directly targeted. ( ie. Event.Target == Event.CurrentTarget )

type ListenerOptions

type ListenerOptions int
const (
	EventTargetOnly ListenerOptions = 1 << iota
	EventQueueAfter
	EventPreventDefault
)

type Model

type Model struct {
	Actions        Actions        `json:"actions"`
	Classes        Classes        `json:"classes"`
	Enumerations   Enumerations   `json:"enums"`
	Events         Events         `json:"events"`
	Instances      Instances      `json:"instances"`
	Aliases        Aliases        `json:"aliases"`
	ParserActions  []ParserAction `json:"parsings"`
	Relations      Relations      `json:"relation"`
	SingleToPlural SingleToPlural `json:"plurals"`
}

Model: Compiled results of a sashimi story.

func (*Model) PrintModel

func (m *Model) PrintModel(printer func(...interface{})) (err error)

type ParserAction

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

ParserAction commands that beome an action

type PropertyModel

type PropertyModel struct {
	Id   ident.Id     `json:"id"`
	Type PropertyType `json:"type"`
	Name string       `json:"name"`
	// pointer, relation
	Relates ident.Id `json:"relates,omitempty"`
	// relation
	Relation ident.Id `json:"relation,omitempty"`
	// num, text, pointer, relation; but, not enum
	IsMany bool `json:"many,omitempty"`
}

type PropertyType

type PropertyType string

type RankedStringIds

type RankedStringIds []ident.Id

RankedStringIds allows a single name to map to multiple resources. Earlier resources are preferred in cases of conflict.

type RelationModel

type RelationModel struct {
	Id     ident.Id      `json:"id"`   // unique id
	Name   string        `json:"name"` // user specified name
	Style  RelationStyle `json:"style"`
	Source ident.Id      `json:"src"` // property ids
	Target ident.Id      `json:"tgt"` // property ids
}

Relation represents a property-pair. Each relation becomes one table.

func (RelationModel) GetOther

func (r RelationModel) GetOther(fromProp ident.Id) (other ident.Id)

func (RelationModel) String

func (r RelationModel) String() string

type RelationStyle

type RelationStyle string

type Relations

type Relations map[ident.Id]*RelationModel

type SingleToPlural

type SingleToPlural map[string]string

type Value

type Value interface{}

Enums are stored as int; Numbers as float64; Pointers as ident.Id; Text as string.

type Values

type Values map[ident.Id]Value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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