qna

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: BSD-3-Clause Imports: 30 Imported by: 0

Documentation

Overview

Package qna provides an implementation of rt.Runtime. ( Its name derives from "questions and answers" - because its the thing that talks to the database. )

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

type Notifier struct {
	StartedScene    func(domains []string)
	EndedScene      func(domains []string)
	ChangedState    func(noun, aspect, oldState, newState string)
	ChangedRelative func(a, b, rel string)
}

Callbacks to listen for system level changes

type Options

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

uses its own cache to preserve values across domain changes

func NewOptions

func NewOptions() Options

func (Options) Option

func (m Options) Option(opt meta.Options) (ret rt.Value, err error)

func (Options) OptionByName

func (m Options) OptionByName(name string) (ret rt.Value, err error)

return an existing option.

func (*Options) SetOption

func (m *Options) SetOption(opt meta.Options, v rt.Value) (err error)

func (*Options) SetOptionByName

func (m *Options) SetOptionByName(name string, v rt.Value) (err error)

change an existing option.

type Randomizer

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

func RandomizedTime

func RandomizedTime() Randomizer

func SeedRandomizer

func SeedRandomizer(seed1, seed2 uint64) Randomizer

func (*Randomizer) Random

func (r *Randomizer) Random(inclusiveMin, exclusiveMax int) int

type Runner

type Runner struct {
	writer.Sink // target for game output
	// contains filtered or unexported fields
}

an implementation of rt.Runtime

func NewRuntime

func NewRuntime(db *sql.DB, d decoder.Decoder) (*Runner, error)

func NewRuntimeOptions

func NewRuntimeOptions(db *sql.DB, d decoder.Decoder, opt Options) (ret *Runner, err error)

func (*Runner) ActivateDomain

func (run *Runner) ActivateDomain(domain string) (err error)

func (*Runner) Call

func (run *Runner) Call(name string, aff affine.Affinity, keys []string, vals []rt.Value) (ret rt.Value, err error)

note: this is mirrored/mimicked in package testpat note: in order to generate appropriate defaults ( ex. a record of the right type ) can return both a both meaningful value *and* an error

func (*Runner) GetField

func (run *Runner) GetField(target, rawField string) (ret rt.Value, err error)

func (*Runner) GetKindByName

func (run *Runner) GetKindByName(rawName string) (ret *rt.Kind, err error)

func (*Runner) LoadGame

func (run *Runner) LoadGame(scene string) (ret string, err error)

produces undefined results if called in the middle of a turn returns the file that was loaded

func (*Runner) PluralOf

func (run *Runner) PluralOf(singular string) (ret string)

func (*Runner) PopScope

func (run *Runner) PopScope()

remove most recently pushed set of variables. ( implements rt.Runtime )

func (*Runner) PushScope

func (run *Runner) PushScope(top rt.Scope)

add the passed set of variables to the pool of current variables ( implements rt.Runtime )

func (*Runner) Random

func (run *Runner) Random(inclusiveMin, exclusiveMax int) int

func (*Runner) ReciprocalsOf

func (run *Runner) ReciprocalsOf(b, rel string) (ret rt.Value, err error)

func (*Runner) RelateTo

func (run *Runner) RelateTo(a, b, rel string) (err error)

doesnt reformat the names.

func (*Runner) RelativesOf

func (run *Runner) RelativesOf(a, rel string) (ret rt.Value, err error)

func (*Runner) SaveGame

func (run *Runner) SaveGame(scene string) (ret string, err error)

produces undefined results if called in the middle of a turn returns the saved file name

func (*Runner) SetField

func (run *Runner) SetField(target, rawField string, val rt.Value) (err error)

func (*Runner) SetNotifier

func (run *Runner) SetNotifier(n Notifier)

func (*Runner) SingularOf

func (run *Runner) SingularOf(plural string) (ret string)

type UserValue

type UserValue struct {
	rt.Value
}

indicates a value stored by the user as opposed to a default read from the db. ( so save knows what to save )

Directories

Path Synopsis
Package decode unpacks stored programs and values from byte slices
Package decode unpacks stored programs and values from byte slices
Package qdb asks specific questions of the play.db for the package qna runtime.
Package qdb asks specific questions of the play.db for the package qna runtime.

Jump to

Keyboard shortcuts

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