Documentation ¶
Index ¶
- type Base
- type Collection
- func (collection *Collection) Count() int
- func (collection *Collection) Create(args ...interface{}) Modellable
- func (collection *Collection) Find(predicate FindPredicate) Modellable
- func (collection *Collection) FindByID(id string) Modellable
- func (collection *Collection) FindOrCreate(predicate FindPredicate) Modellable
- func (collection *Collection) First() Modellable
- func (collection *Collection) GetItems() []Modellable
- type CreateHandler
- type FindPredicate
- type FiniteStateMachine
- func (fsm *FiniteStateMachine) AddStateHandler(stateName string, enterHandler func(string), runHandler func(), ...)
- func (fsm *FiniteStateMachine) Equals(stateName string) bool
- func (fsm *FiniteStateMachine) GetActiveAgent() interface{}
- func (fsm *FiniteStateMachine) GetEndAt() int64
- func (fsm *FiniteStateMachine) GetName() string
- func (fsm *FiniteStateMachine) GoTo(stateName string, item Modellable)
- func (fsm *FiniteStateMachine) IsTurnExpired() bool
- func (fsm *FiniteStateMachine) Run(item Modellable)
- func (fsm *FiniteStateMachine) SetTurn(activeAgent Modellable, endAt time.Time)
- type Manager
- type Modellable
- type StateHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct { ID string `json:"id"` // contains filtered or unexported fields }
Base used to represent base classes for all models
func (*Base) GetCollectionName ¶ added in v0.0.26
func (*Base) Initialize ¶ added in v0.0.21
func (base *Base) Initialize(collection *Collection)
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection used to contain models
func (*Collection) Create ¶
func (collection *Collection) Create(args ...interface{}) Modellable
Create used to create item
func (*Collection) Find ¶
func (collection *Collection) Find(predicate FindPredicate) Modellable
Find used to find item in collection, return nil if not found
func (*Collection) FindByID ¶
func (collection *Collection) FindByID(id string) Modellable
FindByID used to find item in collection by id, return nil if not found
func (*Collection) FindOrCreate ¶
func (collection *Collection) FindOrCreate(predicate FindPredicate) Modellable
FindOrCreate used to find item in collection, create one if not found
func (*Collection) First ¶
func (collection *Collection) First() Modellable
First used to return first item in collection
func (*Collection) GetItems ¶
func (collection *Collection) GetItems() []Modellable
GetItems used to return all items in collections
type CreateHandler ¶ added in v0.0.21
type CreateHandler func(args ...interface{}) Modellable
CreateHandler is alias for func(args ...interface{}) Modellable
type FindPredicate ¶ added in v0.0.21
type FindPredicate func(Modellable) bool
FindPredicate is alias for func(Modellable) bool
type FiniteStateMachine ¶
type FiniteStateMachine struct {
// contains filtered or unexported fields
}
FiniteStateMachine used to implement fsm
func MakeFiniteStateMachine ¶
func MakeFiniteStateMachine(defaultStateName string) *FiniteStateMachine
MakeFiniteStateMachine used to instantiate fsm
func (*FiniteStateMachine) AddStateHandler ¶
func (fsm *FiniteStateMachine) AddStateHandler( stateName string, enterHandler func(string), runHandler func(), exitHandler func(), )
AddStateHandler used to add handler for fsm's state
func (*FiniteStateMachine) Equals ¶
func (fsm *FiniteStateMachine) Equals(stateName string) bool
Equals used to compare fsm's state
func (*FiniteStateMachine) GetActiveAgent ¶
func (fsm *FiniteStateMachine) GetActiveAgent() interface{}
GetActiveAgent used to get fsm's active agent at current turn
func (*FiniteStateMachine) GetEndAt ¶
func (fsm *FiniteStateMachine) GetEndAt() int64
GetEndAt used to get turn's end time
func (*FiniteStateMachine) GetName ¶
func (fsm *FiniteStateMachine) GetName() string
GetName used to get fsm's state name
func (*FiniteStateMachine) GoTo ¶
func (fsm *FiniteStateMachine) GoTo(stateName string, item Modellable)
GoTo used for fsm's state transition
func (*FiniteStateMachine) IsTurnExpired ¶
func (fsm *FiniteStateMachine) IsTurnExpired() bool
IsTurnExpired used to check if turn is expired
func (*FiniteStateMachine) Run ¶
func (fsm *FiniteStateMachine) Run(item Modellable)
Run used to run fsm's state
func (*FiniteStateMachine) SetTurn ¶
func (fsm *FiniteStateMachine) SetTurn(activeAgent Modellable, endAt time.Time)
SetTurn used to set new turn
type Manager ¶ added in v0.0.22
type Manager struct { }
func (*Manager) CreateCollection ¶ added in v0.0.23
func (manager *Manager) CreateCollection(collectionName string, createHandler CreateHandler) *Collection
type Modellable ¶ added in v0.0.21
type Modellable interface { Initialize(*Collection) GetID() string }
type StateHandler ¶
type StateHandler struct {
// contains filtered or unexported fields
}
StateHandler used to