models

package
v0.0.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

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

Base used to represent base classes for all models

func (*Base) GetID

func (base *Base) GetID() string

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

func (collection *Collection) Count() int

Count used to count items

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

func (*Manager) Setup added in v0.0.22

func (manager *Manager) Setup()

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

Jump to

Keyboard shortcuts

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