diff --git a/frontend/client.js b/frontend/client.js index 6a5a78f..0542e8c 100755 --- a/frontend/client.js +++ b/frontend/client.js @@ -398,14 +398,14 @@ class MUDClient { // prompted. // In fact, we should ALWAYS be in a state of just-having-been-prompted. handlePromptMessage(data) { - let [promptText, options = {}] = data; + let [prompt, options = {}] = data; this.shouldReply = true; this.promptOptions = { ...{ class: "prompt" }, ...options }; // - this.writeToOutput(promptText, this.promptOptions); + this.writeToOutput(prompt, this.promptOptions); // // The server has asked for a password, so we set the diff --git a/frontend/style.scss b/frontend/style.scss index c0332ea..1e9b154 100755 --- a/frontend/style.scss +++ b/frontend/style.scss @@ -148,6 +148,6 @@ h2 { } .faint { - opacity: 0.42; + opacity: 0.6; color: #44f; } diff --git a/scenes/authentication/authenticationScene.js b/scenes/authentication/authenticationScene.js index 7c4a066..1e1cd6e 100755 --- a/scenes/authentication/authenticationScene.js +++ b/scenes/authentication/authenticationScene.js @@ -8,7 +8,6 @@ import { gGame } from "../../models/globals.js"; /** @typedef {import("../../models/player.js").Player} Player */ -/** @property {Session} session */ export class AuthenticationScene extends Scene { /** @type {Player} */ player; @@ -54,25 +53,24 @@ export class AuthenticationScene extends Scene { // | __/| | | (_) | | | | | | |_) | |_ // |_| |_| \___/|_| |_| |_| .__/ \__| // |_| +/** @property {AuthenticationScene} scene */ class UsernamePrompt extends Prompt { // - promptText = [ + message = [ "Please enter your username:", // - "(((type *:create* if you want to create a new user)))", // + "((type _*:help*_ to see your other options))", ]; // // When player types :help - helpText = [ - "This is where you log in.", - "If you don't already have a player profile on this server, you can type *:create* to create one", + help = [ + "Enter your username to proceed with loggin in", + "Type _*:create*_ if you are not already registered, and want to create a new account", + "Only a username and password is required - not your email", ]; + options = { username: true }; - // - // Let the client know that we're asking for a username - promptOptions = { username: true }; - - /** @returns {AuthenticationScene} */ + /** @returns {AuthenticationScene} workaround for proper type hinting */ get scene() { return this._scene; } @@ -123,12 +121,8 @@ class UsernamePrompt extends Prompt { // |_| class PasswordPrompt extends Prompt { // - promptText = "Please enter your password"; - - // - // Let the client know that we're asking for a password - // so it can set - promptOptions = { password: true }; + message = "Please enter your password"; + options = { password: true }; get player() { return this.scene.player; diff --git a/scenes/gameLoop/gameScene.js b/scenes/gameLoop/gameScene.js index a7294fb..abe1cc8 100755 --- a/scenes/gameLoop/gameScene.js +++ b/scenes/gameLoop/gameScene.js @@ -38,7 +38,7 @@ export class GameScene extends Scene { } class GameScenePlaceholderPrompt extends Prompt { - promptText = ` + message = ` ▄ █▐▀▀▀▌▄ █ ▐▀▀▀▌▌▓▌ diff --git a/scenes/playerCreation/createUasswprdPrompt.js b/scenes/playerCreation/createUasswprdPrompt.js index e879219..54f0134 100755 --- a/scenes/playerCreation/createUasswprdPrompt.js +++ b/scenes/playerCreation/createUasswprdPrompt.js @@ -4,12 +4,12 @@ import { Config } from "../../config.js"; export class CreatePasswordPrompt extends Prompt { // - promptText = ["Enter a password"]; + message = ["Enter a password"]; // // Let the client know that we're asking for a password // so it can set - promptOptions = { password: true }; + options = { password: true }; get player() { return this.scene.player; diff --git a/scenes/playerCreation/createUsernamePrompt.js b/scenes/playerCreation/createUsernamePrompt.js index ebfb6ad..2cb4da3 100755 --- a/scenes/playerCreation/createUsernamePrompt.js +++ b/scenes/playerCreation/createUsernamePrompt.js @@ -6,14 +6,14 @@ import { gGame } from "../../models/globals.js"; export class CreateUsernamePrompt extends Prompt { // - promptText = [ + message = [ "Enter your username", // "((type *:help* for more info))", // ]; // // When player types :help - helpText = [ + help = [ "Your username.", "It's used, along with your password, when you log in.", "Other players can see it.", @@ -23,7 +23,7 @@ export class CreateUsernamePrompt extends Prompt { // // Let the client know that we're asking for a username - promptOptions = { username: true }; + options = { username: true }; /** @protected @type {PlayerCreationScene} */ _scene; diff --git a/scenes/prompt.js b/scenes/prompt.js index 8c26da1..7ff5f28 100755 --- a/scenes/prompt.js +++ b/scenes/prompt.js @@ -30,19 +30,24 @@ export class Prompt { * Values: string containing the help text * * If you want truly custom help texts, you must override the onHelpFallback function, - * but overriding the onHelp() function gives you more control and skips this helpText + * but overriding the onHelp() function gives you more control and skips this help * dictionary entirely. * * @constant * @readonly * @type {Record} */ - helpText = { - "": "Sorry, no help available. Figure it out yourself, adventurer", // default help text - }; + help = {}; - /** @type {string|string[]} Default prompt text to send if we don't want to send something in the execute() call. */ - promptText = [ + /** + * Default prompt text to send if we don't want to send something in the execute() call. + * + * Array values will be converted to multiline strings with newlines between each string + * in the array. + * + * @type {string|string[]} + */ + message = [ "Please enter some very important info", // Silly placeholder text "((or type :quit to run away))", // strings in double parentheses is rendered shaded/faintly ]; @@ -51,12 +56,12 @@ export class Prompt { /* @example * * // if the prompt expects a username - * promptOptions = { username : true }; + * options = { username : true }; * * // if the prompt expects a password - * promptOptions = { password : true }; + * options = { password : true }; */ - promptOptions = {}; + options = {}; /** @type {Session} */ get session() { @@ -74,27 +79,36 @@ export class Prompt { * It's here you want to send the prompt text via the sendPrompt() method */ execute() { - this.sendPrompt(this.promptText, this.promptOptions); + this.prepareProperties(); + + this.sendPrompt(this.message, this.options); + } + + /** + * Normalize / massage the properties of the Prompt. + * + * This function cannot be called from the Prompt base constructor, as the + * properties of the child class have not been set yet. + */ + prepareProperties() { + // + // Lazy dev set property help = "fooo" instead of help = { "": "fooo" }. + if (this.help && (typeof this.help === "string" || Array.isArray(this.help))) { + this.help = { "": this.help }; + } } /** Triggered when user types `:help [some optional topic]` */ onHelp(topic) { - // - // Fix data formatting shorthand - // So lazy dev set property helpText = "fooo" instead of helpText = { "": "fooo" }. - // - if (typeof this.helpText === "string" || Array.isArray(this.helpText)) { - this.helpText = { "": this.helpText }; - } - - if (this.helpText[topic]) { - this.sendText(this.helpText[topic]); + if (!this.help) { + this.sendText("No help available at this moment - figure it out yourself, adventurer"); + return; + } + + if (this.help[topic]) { + this.sendText(this.help[topic]); return; } - console.log({ - ht: this.helpText, - topic, - }); this.onHelpFallback(topic); } diff --git a/utils/crackdown.js b/utils/crackdown.js index 686b15d..061a97a 100755 --- a/utils/crackdown.js +++ b/utils/crackdown.js @@ -28,6 +28,8 @@ const opcodes = [ ["___", "___", "$1"], // ___underline___ ["(?:[,]{3})", "(?:[,]{3})", "$1"], // ,,,undercurl,,, ["(?:[(]{2})", "(?:[)]{2})", "$1"], // ((faint text)) + ["(?:_\\*)", "(?:\\*_)", "$1"], // _*bold and italic*_ + ["(?:\\*_)", "(?:_\\*)", "$1"], // *_bold and italic_* ["_", "_", "$1"], // _italic_ ["\\*", "\\*", "$1"], // *bold* ["\\[\\[([a-zA-Z0-9_ ]+)\\[\\[", "\\]\\]", "$2"], // [[custom_class[[text with custom class]]