adding goto test command

This commit is contained in:
Dan 2026-01-19 18:48:07 +00:00
parent 901f3e5cdc
commit 1e024b4b2c
4 changed files with 176 additions and 84 deletions

View file

@ -143,6 +143,13 @@ class GameEngine {
return;
}
// Check for debug scene skip command (goto <sceneName>)
if (cmd.startsWith("goto ")) {
const sceneName = commandString.trim().substring(5).trim();
self._debugGoToScene(sceneName);
return;
}
// Pass to input manager if in text mode
if (self.input.getMode() === "text") {
self.input.handleTextInput(commandString);
@ -195,6 +202,23 @@ class GameEngine {
this.terminal.printSuccess(`${this.definition.name} progress has been reset.`);
}
// Debug command to skip to a specific scene
async _debugGoToScene(sceneName) {
const scene = this.scenes.getScene(sceneName);
if (!scene) {
this.adapter.printError(`Scene not found: ${sceneName}`);
this.adapter.print("");
this.adapter.printInfo("Available scenes:");
const sceneNames = Object.keys(this.definition.scenes).sort();
for (const name of sceneNames) {
this.adapter.print(` ${name}`);
}
return;
}
this.adapter.printWarning(`[DEBUG] Skipping to scene: ${sceneName}`);
await this.scenes.goTo(sceneName);
}
// Check if game is currently running
isActive() {
return this.isRunning;

View file

@ -149,9 +149,13 @@ class SceneManager {
continue;
}
// Text with optional className
// Text with optional className (supports html: true for HTML content)
if (block.text !== undefined) {
this._printText(block.text, block.className || "");
if (block.html) {
this._printHTML(block.text, block.className || "");
} else {
this._printText(block.text, block.className || "");
}
continue;
}
}
@ -172,6 +176,21 @@ class SceneManager {
}
}
// Print HTML with variable interpolation
_printHTML(html, className = "") {
// Support ${path} interpolation
const interpolated = html.replace(/\$\{([^}]+)\}/g, (match, path) => {
const value = this.state.get(path);
return value !== undefined ? String(value) : match;
});
if (className) {
this.adapter.printHTML(`<span class="${className}">${interpolated}</span>`);
} else {
this.adapter.printHTML(interpolated);
}
}
// Handle options/choices
async _handleOptions(scene) {
// Filter options based on conditions