This commit is contained in:
Kim Ravn Hansen
2025-09-14 13:04:48 +02:00
parent 8c196bb6a1
commit ed91a7f2f7
43 changed files with 2279 additions and 1727 deletions

58
server/scenes/scene.js Executable file
View File

@@ -0,0 +1,58 @@
import { Session } from "../models/session.js";
import { Prompt } from "./prompt.js";
const MsgContext.ERROR_INSANE_PASSWORD = "Invalid password.";
const MsgContext.ERROR_INCORRECT_PASSWOD = "Incorrect password.";
/**
* @abstract
* @method onReady
*/
export class Scene {
/**
* @type {string|string[]} This text is shown when the scene begins
*/
introText = "";
/** @readonly @constant @type {Session} */
_session;
get session() {
return this._session;
}
/**
* The Prompt that is currently active.
* I.e. the handler for the latest question we asked.
*
* @readonly
* @type {Prompt}
*/
_prompt;
get prompt() {
return this._prompt;
}
constructor() {
}
/** @param {Session} session */
execute(session) {
this._session = session;
if (this.introText) {
this.session.sendText(this.introText);
}
this.onReady();
}
/** @abstract */
onReady() {
throw new Error("Abstract method must be implemented by subclass");
}
/**
* @param {Prompt} prompt
*/
doPrompt(prompt) {
this._prompt = prompt;
prompt.execute();
}
}