@advjs/monorepo / @advjs/core / AdvPlayEngine
Class: AdvPlayEngine
Defined in: packages/core/src/engine/runtime.ts:16
ADV Play Engine - Pure state machine for CLI interactive narrative
Traverses AST children array, advancing currentIndex step by step.
- Dialog/Narration/Text/Scene: format and pause for display
- Choices: pause and wait for choose command
- Code (Camera/Tachie/Background/Go): silently update state, auto-advance
- End: when currentIndex >= children.length
Constructors
Constructor
new AdvPlayEngine(
sessionDir?):AdvPlayEngine
Defined in: packages/core/src/engine/runtime.ts:21
Parameters
sessionDir?
string
Returns
AdvPlayEngine
Methods
choose()
choose(
choiceIndex):Promise<FormattedOutput|null>
Defined in: packages/core/src/engine/runtime.ts:79
Make a choice at the current choices node
Parameters
choiceIndex
number
Returns
Promise<FormattedOutput | null>
getCurrentNode()
getCurrentNode():
FormattedOutput|null
Defined in: packages/core/src/engine/runtime.ts:113
Get the current node output without advancing
Returns
FormattedOutput | null
getSessionManager()
getSessionManager():
SessionManager
Defined in: packages/core/src/engine/runtime.ts:162
Get the session manager for external session operations
Returns
getStatus()
getStatus(): {
background:string;currentIndex:number;sessionId:null;status:"no_session";tachies: { };totalNodes:number; } | {background:string;currentIndex:number;sessionId:string;status:"playing"|"waiting_choice"|"ended";tachies:Record<string, {status:string; }>;totalNodes:number; }
Defined in: packages/core/src/engine/runtime.ts:137
Get current session status
Returns
{ background: string; currentIndex: number; sessionId: null; status: "no_session"; tachies: { }; totalNodes: number; } | { background: string; currentIndex: number; sessionId: string; status: "playing" | "waiting_choice" | "ended"; tachies: Record<string, { status: string; }>; totalNodes: number; }
isEnd()
isEnd():
boolean
Defined in: packages/core/src/engine/runtime.ts:126
Check if the game has ended
Returns
boolean
loadScript()
loadScript(
content,scriptPath,sessionId?):Promise<FormattedOutput|null>
Defined in: packages/core/src/engine/runtime.ts:28
Load a script from markdown content
Parameters
content
string
scriptPath
string
sessionId?
string
Returns
Promise<FormattedOutput | null>
next()
next():
Promise<FormattedOutput|null>
Defined in: packages/core/src/engine/runtime.ts:62
Advance to the next node
Returns
Promise<FormattedOutput | null>
reset()
reset():
Promise<void>
Defined in: packages/core/src/engine/runtime.ts:169
Reset current session
Returns
Promise<void>
resumeSession()
resumeSession(
sessionId):Promise<FormattedOutput|null>
Defined in: packages/core/src/engine/runtime.ts:50
Load from an existing session
Parameters
sessionId
string
Returns
Promise<FormattedOutput | null>