Documentation
¶
Overview ¶
Program written by Ivan Korchmit (c) 2023 Licensed under European Union Public Licence 1.2. For more information, view LICENCE or README
Index ¶
- func AppendText(message string, chatlog io.Writer)
- func BindRooms(room *Room, exit *Exit, otherRooms ...*Room)
- func ErrorBox(message string, app *tview.Application, back tview.Primitive)
- func FetchPlugin[T Plugin](engine *Akevitt) (*T, error)
- func FetchPluginUnsafe[T Plugin](engine *Akevitt) T
- func FilterByType[T any, TCollection any](collection []TCollection) []T
- func Find[T comparable](collection []T, value T) bool
- func FindByKey[TCollection, T comparable](collection []TCollection, selector func(key TCollection) T, value T) *TCollection
- func FindNeighboringRoomByName(currentRoom *Room, name string) (*Room, *Exit, error)
- func LogError(message string)
- func LogInfo(message string)
- func LogWarn(message string)
- func LookupOfType[T Object](room *Room) []T
- func MapSlice[T any, TResult any](l []T, callback func(v T) TResult) []TResult
- func NewEngine() *akevittBuilder
- func PurgeDeadSessions(engine *Akevitt, callback DeadSessionFunc)
- func RemoveItem[T comparable](l []T, item T) []T
- func RemoveItemByIndex[T any](l []T, i int) []T
- type Account
- type ActiveSession
- type Akevitt
- func (engine *Akevitt) AddCommand(command string, function CommandFunc)
- func (engine *Akevitt) AddInit(fn func(*Akevitt, *ActiveSession))
- func (engine *Akevitt) ExecuteCommand(command string, session *ActiveSession) error
- func (engine *Akevitt) GetCommands() []string
- func (engine *Akevitt) GetOnDeadSession() DeadSessionFunc
- func (engine *Akevitt) GetRoom(key uint64) (*Room, error)
- func (engine *Akevitt) GetSessions() Sessions
- func (engine *Akevitt) GetSpawnRoom() *Room
- func (engine *Akevitt) GlobalLookup(room *Room, name string) []Object
- func (engine *Akevitt) Run() error
- func (engine *Akevitt) SaveObject(object Object) error
- type CommandFunc
- type DatabasePlugin
- type DeadSessionFunc
- type Exit
- type Object
- type Pair
- type Plugin
- type Room
- type Sessions
- type UIFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendText ¶
func FetchPlugin ¶
func FetchPluginUnsafe ¶
func FilterByType ¶
func FindByKey ¶
func FindByKey[TCollection, T comparable](collection []TCollection, selector func(key TCollection) T, value T) *TCollection
func LookupOfType ¶
func PurgeDeadSessions ¶
func PurgeDeadSessions(engine *Akevitt, callback DeadSessionFunc)
func RemoveItem ¶
func RemoveItem[T comparable](l []T, item T) []T
Removes item from collection and returns it.
func RemoveItemByIndex ¶
Types ¶
type Account ¶
Basic structure for storing credential information. After registering an account, the password is hashed in a proper way To create one you would need to invoke `engine.Register(username, password, session)`
type ActiveSession ¶
type ActiveSession struct {
Account *Account
Application *tview.Application
Data map[string]any
}
type Akevitt ¶
type Akevitt struct {
// contains filtered or unexported fields
}
func (*Akevitt) AddCommand ¶
func (engine *Akevitt) AddCommand(command string, function CommandFunc)
Register command with an alias and function
func (*Akevitt) AddInit ¶
func (engine *Akevitt) AddInit(fn func(*Akevitt, *ActiveSession))
func (*Akevitt) ExecuteCommand ¶
func (engine *Akevitt) ExecuteCommand(command string, session *ActiveSession) error
Execute the command specified in a `command`. The command can be registered using the useRegisterCommand method. Returns an error if the given command not found or the result of associated function returns an error.
func (*Akevitt) GetCommands ¶
Gets currently registered commands. This is useful if your game implements auto-completion.
func (*Akevitt) GetOnDeadSession ¶
func (engine *Akevitt) GetOnDeadSession() DeadSessionFunc
func (*Akevitt) GetRoom ¶
Obtains currently loaded rooms by key. It will return an error if room not found.
func (*Akevitt) GetSessions ¶
func (*Akevitt) GetSpawnRoom ¶
Get sspawn room if specified. Useful for setting character's initial room during its creation.
func (*Akevitt) GlobalLookup ¶
func (*Akevitt) Run ¶
Run the given instance of engine. You should pass your own implementation of ActiveSession, so it can be controlled of how your game would behave
func (*Akevitt) SaveObject ¶
Saves object into a database.
type CommandFunc ¶
type CommandFunc = func(engine *Akevitt, session *ActiveSession, arguments string) error
type DatabasePlugin ¶
type DeadSessionFunc ¶
type DeadSessionFunc = func(deadSession *ActiveSession, liveSessions []*ActiveSession, engine *Akevitt)
type Exit ¶
type Exit struct {
Room *Room
OnPreEnter func(*Akevitt, *ActiveSession) error
}
func IsRoomReachable ¶
func IsRoomReachable[T Room](engine *Akevitt, session *ActiveSession, name string, currentRoomKey uint64) (*Exit, error)
Checks if current room specified reachable to another room.
type Room ¶
type Room struct {
Name string
Exits []*Exit
Objects []Object
OnPreEnter func(*Akevitt, *ActiveSession, *Exit) error
}
type Sessions ¶
type Sessions = map[ssh.Session]*ActiveSession