package condition
import "git.teletypegames.org/engines/inkwell/inkbase/condition"
Package condition holds the generic conditions: the ones that need nothing but the inkbase.State in the Ctx, or at most a narrow host interface any game can implement.
A condition is an inkbase.Condition: Eval(ctx) bool. It is stateless and evaluated lazily, every time it is asked, so it always answers for the game as it stands. The constructors:
- Not, And and Or combine conditions.
- Flag holds while a State flag is raised.
- VarEq holds while a State var equals a value, by Go's ==.
- Knows holds once the player has come to know an entity (its State.Known is above zero).
- OnStage and OnWorld ask a StageReader which Stage is showing.
- Started asks a StartedReader whether a session exists.
For example, a widget that shows only on the world while a flag is down:
When: condition.And(condition.OnWorld(), condition.Not(condition.Flag("cutscene")))
The adventure conditions (HasItem, InScene, Given, …) are in the inkwell cond package, and the root inkwell package re-exports both sets.
Index
- func And(cs ...inkbase.Condition) inkbase.Condition
- func Flag(name string) inkbase.Condition
- func Knows(entity inkbase.Knowable) inkbase.Condition
- func Not(c inkbase.Condition) inkbase.Condition
- func OnStage(s *stage.Stage) inkbase.Condition
- func OnWorld() inkbase.Condition
- func Or(cs ...inkbase.Condition) inkbase.Condition
- func Started() inkbase.Condition
- func VarEq(name string, v any) inkbase.Condition
- type StageReader
- type StartedReader
Functions
func And
func And(cs ...inkbase.Condition) inkbase.Condition
And holds when every one of its conditions does.
func Flag
func Flag(name string) inkbase.Condition
Flag holds while a named world-state flag is raised.
func Knows
func Knows(entity inkbase.Knowable) inkbase.Condition
Knows is true while the player has met the entity.
func Not
func Not(c inkbase.Condition) inkbase.Condition
Not holds when the condition it wraps does not.
func OnStage
func OnStage(s *stage.Stage) inkbase.Condition
OnStage is true while the given Stage is the one showing.
func OnWorld
func OnWorld() inkbase.Condition
OnWorld is true while the Stage showing is the world.
func Or
func Or(cs ...inkbase.Condition) inkbase.Condition
Or holds when any one of its conditions does.
func Started
func Started() inkbase.Condition
Started is true once a session exists.
func VarEq
func VarEq(name string, v any) inkbase.Condition
VarEq holds while a world-state variable compares equal to a value.
Types
type StageReader
type StageReader interface { CurrentStage() *stage.Stage OnWorldStage() bool }
StageReader provides the current stage for conditions.
type StartedReader
type StartedReader interface { Started() bool }
StartedReader reports whether a session has begun.