import { LogicAction } from "../action/logicAction"; import { Actionable } from "../action/actionable"; import { Chained, Proxied } from "../action/chain"; import { Sentence, SentencePrompt } from "../elements/character/sentence"; import Actions = LogicAction.Actions; import { ActionStatements, LambdaHandler } from "./type"; import { Lambda } from "./condition"; export type MenuConfig = {}; export type MenuChoice = { action: ActionStatements; prompt: SentencePrompt | Sentence; config?: { disabled?: Lambda | LambdaHandler; hidden?: Lambda | LambdaHandler; }; }; export type Choice = { action: Actions[]; prompt: Sentence; config: ChoiceConfig; }; export type MenuData = { prompt: Sentence | null; choices: Choice[]; }; export type ChoiceConfig = { disabled?: Lambda; hidden?: Lambda; }; export declare class Menu extends Actionable { /** * Create a menu with a prompt * @param prompt - The prompt to display to the player * @returns A new menu * @example * ```ts * Menu.prompt("What should I do?").choose("Go left", [ * character.say("I went left") * ]); * ``` */ static prompt(prompt: SentencePrompt | Sentence | null | undefined, config?: MenuConfig): Menu; static choose(arg0: Sentence | MenuChoice | SentencePrompt, arg1?: ActionStatements): Proxied>; constructor(prompt: SentencePrompt, config?: MenuConfig); constructor(prompt: Sentence, config?: MenuConfig); constructor(prompt: SentencePrompt | Sentence, config: MenuConfig); constructor(prompt: null, config?: MenuConfig); constructor(prompt: SentencePrompt | Sentence | null, config: MenuConfig); /** * Add a choice to the menu. * @param choice - A `MenuChoice` or pair of `Sentence`/prompt and actions. * @param action - Optional statement list when the first argument is a prompt. * @example * ```ts * menu.choose("Go left", [ * character.say("I went left") * ]); * ``` * @chainable */ choose(choice: MenuChoice): Proxied>; choose(prompt: Sentence, action: ActionStatements): Proxied>; choose(prompt: SentencePrompt, action: ActionStatements): Proxied>; choose(arg0: Sentence | MenuChoice | SentencePrompt, arg1?: ActionStatements): Proxied>; /** * Magic method to hide the last choice if the condition is true. * @param condition - Condition used to decide whether to hide. * @example * ```ts * menu.choose(...).hideIf(persis.isTrue("flag")); * ``` * **Note**: This method will override the last choice's config.hidden */ hideIf(condition: Lambda | LambdaHandler): Proxied>; /** * Magic method to disable the last choice if the condition is true. * @param condition - Condition used to disable the choice. * @example * ```ts * menu.choose(...).disableIf(persis.isTrue("flag")); * ``` */ disableIf(condition: Lambda | LambdaHandler): Proxied>; /** * Add a choice that is enabled only when the condition is true. * @param condition - Condition guarding the choice. * @param prompt - Prompt when presenting the choice. * @param action - Actions executed when the choice is selected. * @example * ```ts * menu.enableWhen(persis.isTrue("flag"), "Go left", [ * character.say("I went left") * ]); * ``` */ enableWhen(condition: Lambda | LambdaHandler, prompt: Sentence | SentencePrompt, action: ActionStatements): Proxied>; /** * Add a choice that is visible only when the condition is true. * @param condition - Condition that controls visibility. * @param prompt - Prompt displayed for the choice. * @param action - Actions executed when the choice is selected. * @example * ```ts * menu.showWhen(persis.isTrue("flag"), "Go left", [ * character.say("I went left") * ]); * ``` */ showWhen(condition: Lambda | LambdaHandler, prompt: Sentence | SentencePrompt, action: ActionStatements): Proxied>; }