goink

package module
v0.0.0-...-72a8923 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

README

goink

Go golangci-lint Coverage Status Go Report Card

This is a go rewrite of inkle's ink, a scripting language for writing interactive narrative.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PathSplit of the node's path
	PathSplit string = "__"
)

Functions

This section is empty.

Types

type CanNext

type CanNext interface {
	Next() (Node, error)
	SetNext(node Node)
	Render() (text string, tags []string)
}

CanNext content - which can go next

type Choices

type Choices interface {
	Pick(idx int) (Node, error)
	List() (text []string, tags [][]string)
}

Choices content - which has one/more option(s)

type Context

type Context struct {
	Current string                 `json:"current" binding:"required"`
	LN      int                    `json:"ln" binding:"required"`
	Vars    map[string]interface{} `json:"vars"`
}

Context of the story

func NewContext

func NewContext() *Context

NewContext which starts from beginning with empty vars

type End

type End interface {
	End() (text string, tags []string)
}

End of story

type ErrInk

type ErrInk struct {
	LN      int    `json:"ln" binding:"required"`
	Message string `json:"msg" binding:"required"`
}

ErrInk for transporting the error info

func (*ErrInk) Error

func (e *ErrInk) Error() string

func (ErrInk) Wrap

func (e ErrInk) Wrap(err error) []error

Wrap errors

type Node

type Node interface {
	Story() *Story
	Parent() Node
	PostParsing() error

	Path() string
	LN() int
}

Node is the basic element of a story

type ParseFunc

type ParseFunc func(s *Story, input string, ln int) error

ParseFunc of the story

type Section

type Section struct {
	Text string   `json:"text"`
	Tags []string `json:"tags"`

	Opts     []string   `json:"opts"`
	OptsTags [][]string `json:"optsTags"`

	End bool `json:"end" binding:"required"`
}

Section is rendered result of current story

type Story

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

Story of the ink

func Default

func Default() *Story

Default story

func (*Story) Parse

func (s *Story) Parse(input string) *ErrInk

Parse the input text

func (*Story) Pick

func (s *Story) Pick(ctx *Context, idx int) (sec *Section, err *ErrInk)

Pick the option

func (*Story) PostParsing

func (s *Story) PostParsing() (errs []*ErrInk)

PostParsing when all input parsing has done

func (*Story) Resume

func (s *Story) Resume(ctx *Context) (sec *Section, err *ErrInk)

Resume the story

func (*Story) SetID

func (s *Story) SetID(id string)

SetID of the story

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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