* Load a script from markdown content
(content: string, scriptPath: string, sessionId?: string)
| 73 | return this.advanceToNextDisplayable() |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Make a choice at the current choices node |
| 78 | */ |
| 79 | async choose(choiceIndex: number): Promise<FormattedOutput | null> { |
| 80 | if (!this.ast || !this.session) |
| 81 | return null |
| 82 | |
| 83 | if (this.session.status !== 'waiting_choice') |
| 84 | return null |
| 85 | |
| 86 | const currentNode = this.ast.children[this.session.currentIndex] |
| 87 | if (currentNode?.type !== 'choices') |
| 88 | return null |
| 89 | |
| 90 | const choices = currentNode as AdvAst.Choices |
| 91 | if (choiceIndex < 1 || choiceIndex > choices.choices.length) |
| 92 | return null |
| 93 | |
| 94 | // Record the choice |
| 95 | this.session.choices[this.session.currentIndex] = choiceIndex |
no test coverage detected