You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.7 KiB
69 lines
2.7 KiB
import {ListQuestion, Separator} from "inquirer";
|
|
import {personaPossessive, PersonaPrompt} from "../../datatypes/Persona";
|
|
import chalk from "chalk";
|
|
import {EntryMainMenuChoice, makeEntryMainMenuChoice} from "./EntryMainMenuPrompt";
|
|
import {asDefault, identity} from "../../utils/Objects";
|
|
import {InquireFunction} from "../Inquire";
|
|
import {Condition} from "../../datatypes/Condition";
|
|
|
|
export interface ConditionPromptOptions extends Partial<Omit<ListQuestion, "name" | "type" | "choices">>, PersonaPrompt {
|
|
}
|
|
|
|
export interface ConditionPromptDependencies {
|
|
readonly inquire: InquireFunction
|
|
}
|
|
|
|
export function conditionPrompt(deps: ConditionPromptDependencies): {
|
|
(options: ConditionPromptOptions): Promise<Condition>,
|
|
mainMenu: EntryMainMenuChoice<"condition">,
|
|
} {
|
|
return makeEntryMainMenuChoice({
|
|
property: "condition",
|
|
name: (input) => `Change condition ${chalk.dim(`(currently ${chalk.greenBright(input)})`)}`,
|
|
key: "c",
|
|
injected: (options) => promptForCondition(options, deps),
|
|
toOptions: asDefault,
|
|
toProperty: identity,
|
|
})
|
|
}
|
|
|
|
export async function promptForCondition(options: ConditionPromptOptions = {}, {inquire}: ConditionPromptDependencies): Promise<Condition> {
|
|
return await inquire({
|
|
type: "list",
|
|
message: `How's ${personaPossessive(options.persona)} current condition?`,
|
|
choices: [
|
|
{
|
|
value: Condition.CRITICAL,
|
|
name: `Critical ${chalk.dim("(very uncomfortable/very unpleasant feelings/completely out of control)")}`
|
|
},
|
|
{
|
|
value: Condition.POOR,
|
|
name: `Poor ${chalk.dim("(uncomfortable/unpleasant feelings/losing control)")}`
|
|
},
|
|
{
|
|
value: Condition.SOSO,
|
|
name: `So-so ${chalk.dim("(OK/neutral mood/mixed feelings/close to losing control)")}`
|
|
},
|
|
{
|
|
value: Condition.GOOD,
|
|
name: `Good ${chalk.dim("(comfortable/pleasant feelings/mostly in control)")}`
|
|
},
|
|
{
|
|
value: Condition.EXCELLENT,
|
|
name: `Excellent ${chalk.dim("(very comfortable/very pleasant feelings/secure/in control)")}`
|
|
},
|
|
new Separator(),
|
|
{
|
|
value: Condition.NUMB,
|
|
name: `Numb ${chalk.dim("(depressive void state/crystallizing/petrifying/encased in ice)")}`
|
|
},
|
|
{
|
|
value: Condition.UNSURE,
|
|
name: `Unsure ${chalk.dim("(strong mixed feelings/low connection to self)")}`
|
|
},
|
|
],
|
|
default: 2,
|
|
pageSize: 999,
|
|
...options,
|
|
})
|
|
} |