dialogs

package
v0.0.0-...-332bf77 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DOT_ALWAYS = 1
View Source
const DOT_SINGLE = 0

Variables

This section is empty.

Functions

func RefTrue

func RefTrue() *bool

func WriteToFile

func WriteToFile(dialog *Dialog, fileName string)

Types

type Dialog

type Dialog struct {
	ID   string `bson:"id,omitempty" json:"id,omitempty" yaml:"id,omitempty"`
	Text string `bson:"text,omitempty" json:"text,omitempty" yaml:"text"`
	// if AlternateTexts is not empty then the text should be randomly selected
	AlternateTexts []string `bson:"alternateTexts,omitempty" json:"alternateTexts,omitempty" yaml:"alternateTexts,omitempty"`
	// if ordered texts is set the shown text will be based on how many times you visited the dialog
	OrderedTexts *bool `bson:"orderedTexts,omitempty" json:"orderedTexts,omitempty" yaml:"orderedTexts,omitempty"`

	// a dialog either has options the player can choose from or it has a response that is shown to the player.
	Options                []*Dialog `bson:"options,omitempty" json:"options,omitempty" yaml:"options,omitempty"`
	Answer                 *Dialog   `bson:"answer,omitempty" json:"answer,omitempty" yaml:"answer,omitempty"`
	RequiresVisitedDialogs []string  `bson:"requires_visited_dialogs,omitempty" json:"requires_visited_dialogs,omitempty" yaml:"requires_visited_dialogs,omitempty"`
	ShowOnlyOnce           *bool     `bson:"show_only_once,omitempty" json:"show_only_once,omitempty" yaml:"show_only_once,omitempty"`
	//	HasAnswer              *bool         `bson:"has_answer,omitempty" json:"has_answer,omitempty" yaml:"has_answer,omitempty"`
	IsDialogExit *bool `bson:"is_dialog_exit,omitempty" json:"is_dialog_exit,omitempty" yaml:"is_dialog_exit,omitempty"`
}

Dialog ...

func NewDialog

func NewDialog(id string, text string, options []*Dialog, showOnlyOnce *bool) *Dialog

create a new Dialog

func NewDialogWithRequirements

func NewDialogWithRequirements(id string, text string, options []*Dialog, showOnlyOnce *bool, visited ...string) *Dialog

func ReadFromFile

func ReadFromFile(fileName string) *Dialog

func (*Dialog) FindDialog

func (d *Dialog) FindDialog(id string) *Dialog

FindDialogue ...

func (*Dialog) GetText

func (d *Dialog) GetText() string

func (*Dialog) Render

func (d *Dialog) Render(state *DialogState) string

func (*Dialog) RenderPlain

func (d *Dialog) RenderPlain(state *DialogState) string

type DialogOptionType

type DialogOptionType int

create DialogOptionType enum with options SINGLE and ALWAYS

type DialogOptions

type DialogOptions []*Dialog

func NewResponse

func NewResponse(id string, text string) DialogOptions

creates a dialog that is used as a response (defaults to DOT_ALWAYS)

func Options

func Options(dialogs ...*Dialog) DialogOptions

create dialog map structure and add all parameters to it

type DialogState

type DialogState struct {
	CurrentDialogID string
	// DialogVisited stores how many times a dialog has been visited
	DialogVisited  map[string]int
	Context        map[string]string
	DynamicContext map[string]func() string
}

func NewDialogState

func NewDialogState() *DialogState

type Executor

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

Jump to

Keyboard shortcuts

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