Documentation
¶
Index ¶
- Constants
- Variables
- func Init(c Container, listDefs ListDefs) (Element, Evaluator)
- func LoadJSON(r io.Reader) (Container, ListDefs, error)
- type Address
- type BaseEvaluator
- type BeginEval
- type BeginStringEval
- type BeginTag
- type BinOp
- type BoolValue
- type CallFrame
- func (f *CallFrame) ChoiceCount() int
- func (f *CallFrame) DeclareLocal(name string, value Value) *CallFrame
- func (f *CallFrame) GetVar(name string) (Value, bool)
- func (f *CallFrame) IncChoiceCount() *CallFrame
- func (f *CallFrame) IncTurnCount() *CallFrame
- func (f *CallFrame) ListAll(v ListValue) ListValue
- func (f *CallFrame) ListInt(origin string, value int) ListValue
- func (f *CallFrame) PopFrame() (*CallFrame, Element, Stepper, bool)
- func (f *CallFrame) PopVal() (Value, *CallFrame)
- func (f *CallFrame) PushFrame(returnTo Element, retStep Stepper, isFunction bool) *CallFrame
- func (f *CallFrame) PushVal(v Value) *CallFrame
- func (f *CallFrame) PushVarRef(name string) *CallFrame
- func (f *CallFrame) ResetChoiceCount() *CallFrame
- func (f *CallFrame) TurnsSince(addr Address) int
- func (f *CallFrame) UpdateVar(name string, v Value) *CallFrame
- func (f *CallFrame) Visit(addr VisitAddr, from Address) *CallFrame
- func (f *CallFrame) VisitCount(addr Address) int
- func (f *CallFrame) WithGlobal(name string, value Value) *CallFrame
- func (f *CallFrame) WithLocal(name string, value Value) *CallFrame
- type Choice
- type ChoiceCounter
- type ChoicePoint
- type ChoicePointFlag
- type Container
- type ContainerElement
- type ContainerFlag
- type Divert
- type DivertTargetValue
- type Done
- type DupTop
- type Element
- type End
- type EndEval
- type EndStringEval
- type EndTag
- type EvalEvaluator
- type EvalFrame
- type Evaluator
- type FloatValue
- type FuncCall
- type FuncReturn
- type GetVar
- type GetVisitCount
- type Glue
- type IntValue
- type ListAllFunc
- type ListCountFunc
- type ListDefs
- type ListInt
- type ListIntersectFunc
- type ListInvertFunc
- type ListItem
- type ListMaxFunc
- type ListMinFunc
- type ListRangeFunc
- type ListValue
- func (l ListValue) Add(v Value) ListValue
- func (l ListValue) At(index int) ListValue
- func (l ListValue) Contains(v ListValue) bool
- func (l ListValue) Eq(v Value) bool
- func (l ListValue) Intersect(v ListValue) ListValue
- func (l ListValue) Lt(v Value) bool
- func (l ListValue) Lte(v Value) bool
- func (l ListValue) Output() Output
- func (l ListValue) Put(origin, name string, value int) ListValue
- func (l ListValue) Range(start, stop Value) ListValue
- func (l ListValue) Resolve(defs ListDefs) ListValue
- func (l ListValue) Sub(v Value) ListValue
- func (l ListValue) Updated(v Value) Value
- type ListValueFunc
- type Newline
- type NoOp
- type Node
- type Out
- type Output
- type Outputter
- type Pop
- type ReadCountFunc
- type Seq
- type SetTemp
- type SetVar
- type StepEvaluator
- type Stepper
- type StringEvaluator
- type StringValue
- type StringWrappedEvaluator
- type TagEvaluator
- type Text
- type ThreadStart
- type TunnelCall
- type TunnelReturn
- type TurnCounter
- type TurnsSince
- type UnaryOp
- type Value
- type VarRef
- type Vars
- type VarsFrame
- type Visit
- type VisitAddr
- type VisitIndex
- type Void
- type VoidValue
Constants ¶
View Source
const ( MinInkVersion = 19 MaxInkVersion = 21 )
Variables ¶
View Source
var ErrUnsupportedVersion = fmt.Errorf("unsupported version")
Functions ¶
Types ¶
type BaseEvaluator ¶
type BaseEvaluator struct {
}
type BeginStringEval ¶
type BeginStringEval struct{} // "str"
type BinOp ¶
var Add BinOp = func(a, b Value) Value { switch a := a.(type) { case StringValue: return a + asStringValue(b) } switch bt := b.(type) { case StringValue: return asStringValue(a) + bt case FloatValue: a = asFloat(a) case BoolValue: b = boolInt(bt) } switch a := a.(type) { case FloatValue: return a + asFloat(b) case IntValue: return a + b.(IntValue) case ListValue: return a.Add(b) case BoolValue: return boolInt(a) + b.(IntValue) default: panic(fmt.Errorf("unsupported type %T", a)) } }
var Div BinOp = func(a, b Value) Value { switch bt := b.(type) { case FloatValue: a = asFloat(a) case BoolValue: b = boolInt(bt) } switch a := a.(type) { case FloatValue: return a / asFloat(b) case IntValue: return a / b.(IntValue) case BoolValue: return boolInt(a) / b.(IntValue) default: panic(fmt.Errorf("unsupported type %T", a)) } }
var Eq BinOp = func(a, b Value) Value { if eq, ok := a.(interface { Eq(b Value) bool }); ok { return boolean(eq.Eq(b)) } if _, ok := a.(StringValue); ok { b = asStringValue(b) } else if _, ok := b.(StringValue); ok { a = asStringValue(a) } return boolean(a == b) }
var Mod BinOp = func(a, b Value) Value { switch bt := b.(type) { case FloatValue: a = asFloat(a) case BoolValue: b = boolInt(bt) } switch a := a.(type) { case FloatValue: return FloatValue(math.Mod(float64(a), float64(asFloat(b)))) case IntValue: return a % b.(IntValue) case BoolValue: return boolInt(a) % b.(IntValue) default: panic(fmt.Errorf("unsupported type %T", a)) } }
var Mul BinOp = func(a, b Value) Value { switch bt := b.(type) { case FloatValue: a = asFloat(a) case BoolValue: b = boolInt(bt) } switch a := a.(type) { case FloatValue: return a * asFloat(b) case IntValue: return a * b.(IntValue) case BoolValue: return boolInt(a) * b.(IntValue) default: panic(fmt.Errorf("unsupported type %T", a)) } }
var Sub BinOp = func(a, b Value) Value { switch bt := b.(type) { case FloatValue: a = asFloat(a) case BoolValue: b = boolInt(bt) } switch a := a.(type) { case FloatValue: return a - asFloat(b) case IntValue: return a - b.(IntValue) case ListValue: return a.Sub(b) case BoolValue: return boolInt(a) - b.(IntValue) default: panic(fmt.Errorf("unsupported type %T", a)) } }
type CallFrame ¶
type CallFrame struct {
// contains filtered or unexported fields
}
func (*CallFrame) ChoiceCount ¶
func (*CallFrame) DeclareLocal ¶
func (*CallFrame) IncChoiceCount ¶
func (*CallFrame) IncTurnCount ¶
func (*CallFrame) PushVarRef ¶
func (*CallFrame) ResetChoiceCount ¶
func (*CallFrame) TurnsSince ¶
func (*CallFrame) VisitCount ¶
type ChoiceCounter ¶
type ChoiceCounter struct{} // "choiceCnt"
type ChoicePoint ¶
type ChoicePoint struct {
Dest Address `json:"*"`
Flags ChoicePointFlag `json:"flg"`
}
type ChoicePointFlag ¶
type ChoicePointFlag uint32
const ( HasCondition ChoicePointFlag = 0x01 // Has condition?: Set if the story should pop a value from the evaluation stack in order to determine whether a choice instance should be created at all. HasStartContent ChoicePointFlag = 0x02 // Has start content? - According to square bracket notation, is there any leading content before any square brackets? If so, this content should be popped from the evaluation stack. HasChoiceOnlyContent ChoicePointFlag = 0x04 // Has choice-only content? - According to square bracket notation, is there any content between the square brackets? If so, this content should be popped from the evaluation stack. IsInvisibleDefault ChoicePointFlag = 0x08 // Is invisible default? - When this is enabled, the choice isn't provided to the game (isn't presented to the player), and instead is automatically followed if there are no other choices generated. OnceOnly ChoicePointFlag = 0x10 // Once only? - Defaults to true. This is the difference between the * and + choice bullets in ink. If once only (*), the choice is only displayed if its target container's read count is zero. )
type Container ¶
type Container struct {
Name string
Parent *Container
ParentIndex *int
Flags ContainerFlag
Contents []Node
Nested map[string]Container
}
func LoadContainer ¶
type ContainerElement ¶
func (ContainerElement) Address ¶
func (e ContainerElement) Address() (Address, int)
func (ContainerElement) Flatten ¶
func (e ContainerElement) Flatten() (*ContainerElement, []VisitAddr)
func (ContainerElement) Next ¶
func (e ContainerElement) Next() (Element, []VisitAddr)
func (ContainerElement) Node ¶
func (e ContainerElement) Node() Node
type ContainerFlag ¶
type ContainerFlag uint32
const ( RecordVisits ContainerFlag = 0x1 // The story should keep a record of the number of visits to this container. CountTurns ContainerFlag = 0x2 // The story should keep a record of the number of the turn index that this container was lasted visited. CountStartOnly ContainerFlag = 0x4 // For the above numbers, the story should only record changes when the story visits the very first subelement, rather than random entry at any point. Used to distinguish the different behaviour between knots and stitches (random access), versus gather points and choices (count start only). )
type DivertTargetValue ¶
type DivertTargetValue struct {
Dest Address `json:"^->"`
}
type Done ¶
type Done struct{}
Tries to close/pop the active thread, otherwise marks the story flow safe to exit without a loose end warning.
type End ¶
type End struct{}
Ends the story flow immediately, closes all active threads, unwinds the callstack, and removes any choices that were previously created.
type EndStringEval ¶
type EndStringEval struct{} // "/str"
type EvalEvaluator ¶
type EvalEvaluator struct {
Prev Stepper
}
type FloatValue ¶
type FloatValue float64
func (FloatValue) Output ¶
func (f FloatValue) Output() Output
type FuncReturn ¶
type FuncReturn struct{} // "~ret"
type GetVisitCount ¶
type GetVisitCount struct {
Container string `json:"CNT?"`
}
type ListAllFunc ¶
type ListAllFunc struct{} // "LIST_ALL"
type ListCountFunc ¶
type ListCountFunc struct{} // "LIST_COUNT"
type ListIntersectFunc ¶
type ListIntersectFunc struct{} // "L^"
type ListInvertFunc ¶
type ListInvertFunc struct{} // "LIST_INVERT"
type ListMaxFunc ¶
type ListMaxFunc struct{} // "LIST_MAX"
type ListMinFunc ¶
type ListMinFunc struct{} // "LIST_MIN"
type ListRangeFunc ¶
type ListRangeFunc struct{} // "range"
type ListValue ¶
type ListValue struct {
Items []ListItem `json:"list"`
Origins map[string]struct{} `json:"origins"`
}
func ListSingle ¶
type ListValueFunc ¶
type ListValueFunc struct{} // "LIST_VALUE"
type ReadCountFunc ¶
type ReadCountFunc struct{} // "readc"
type StepEvaluator ¶
type StringEvaluator ¶
type StringEvaluator struct {
Prev Stepper
// contains filtered or unexported fields
}
type StringValue ¶
type StringValue string // "^text"
func (StringValue) Output ¶
func (s StringValue) Output() Output
type StringWrappedEvaluator ¶
type StringWrappedEvaluator struct {
// contains filtered or unexported fields
}
type TagEvaluator ¶
type TagEvaluator struct {
Prev Stepper
}
type ThreadStart ¶
type ThreadStart struct{} // "thread"
type TunnelCall ¶
type TunnelReturn ¶
type TunnelReturn struct{} // "->->"
type TurnCounter ¶
type TurnCounter struct{} // "turn"
type TurnsSince ¶
type TurnsSince struct{} // "turns"
type VisitAddr ¶
type VisitAddr struct {
Addr Address
Flags ContainerFlag
EntryIndex int
}
type VisitIndex ¶
type VisitIndex struct{} // "visit"
Click to show internal directories.
Click to hide internal directories.