From 9afe8b489e4cee0c873b6fefc6b4c65523e29a45 Mon Sep 17 00:00:00 2001 From: raeleus Date: Sun, 29 Sep 2024 09:10:53 -0700 Subject: [PATCH] Added #renamecharacter. --- Input.js | 23 ++++++++++++++++++++++- Output.js | 2 ++ README.md | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Input.js b/Input.js index efd1a87..daf3bd7 100644 --- a/Input.js +++ b/Input.js @@ -1,5 +1,7 @@ const rollSynonyms = ["roll"] const createSynonyms = ["create", "generate", "start", "begin", "setup", "party", "member", "new"] +const renameCharacterSynonyms = ["renamecharacter", "renameperson"] +const cloneCharacterSynonyms = ["clonecharacter", "cloneperson", "copycharacter", "copyperson"] const bioSynonyms = ["bio", "biography", "summary", "character", "charactersheet", "statsheet"] const setClassSynonyms = ["setclass", "class"] const setSummarySynonyms = ["setsummary", "summary"] @@ -82,7 +84,7 @@ const modifier = (text) => { return { text } } - if (!found) found = processCommandSynonyms(command, commandName, helpSynonyms.concat(rollSynonyms, noteSynonyms, eraseNoteSynonyms, showNotesSynonyms, clearNotesSynonyms, showCharactersSynonyms, removeCharacterSynonyms, generateNameSynonyms, setDefaultDifficultySynonyms, showDefaultDifficultySynonyms, resetSynonyms), function () {return true}) + if (!found) found = processCommandSynonyms(command, commandName, helpSynonyms.concat(rollSynonyms, noteSynonyms, eraseNoteSynonyms, showNotesSynonyms, clearNotesSynonyms, showCharactersSynonyms, removeCharacterSynonyms, generateNameSynonyms, setDefaultDifficultySynonyms, showDefaultDifficultySynonyms, renameCharacterSynonyms, cloneCharacterSynonyms, resetSynonyms), function () {return true}) if (found == null) { if (state.characterName == null) { @@ -148,6 +150,8 @@ const modifier = (text) => { if (text == null) text = processCommandSynonyms(command, commandName, setDefaultDifficultySynonyms, doSetDefaultDifficulty) if (text == null) text = processCommandSynonyms(command, commandName, showDefaultDifficultySynonyms, doShowDefaultDifficulty) if (text == null) text = processCommandSynonyms(command, commandName, generateNameSynonyms, doGenerateName) + if (text == null) text = processCommandSynonyms(command, commandName, renameCharacterSynonyms, doRenameCharacter) + // if (text == null) text = processCommandSynonyms(command, commandName, cloneCharacterSynonyms, doCloneCharacter) if (text == null) text = processCommandSynonyms(command, commandName, helpSynonyms, doHelp) if (text == null) { var character = getCharacter() @@ -569,6 +573,23 @@ function doBio(command) { return " " } +function doRenameCharacter(command) { + var character = getCharacter() + var arg0 = getArgumentRemainder(command, 0) + if (arg0 == null) { + state.show = "none" + return "\n[Error: Not enough parameters. See #help]\n" + } + var possessiveName = getPossessiveName(character.name) + + state.show = "none" + var text = `\n[${possessiveName} name has been changed to ${arg0}]\n` + + character.name = arg0 + + return text +} + function doSetStat(command) { var character = getCharacter() var arg0 = getArgument(command, 0) diff --git a/Output.js b/Output.js index 29c4548..e5209d8 100644 --- a/Output.js +++ b/Output.js @@ -205,6 +205,8 @@ const modifier = (text) => { text += "\n Launches the create character setup." text += "\n#bio" text += "\n Shows the character's abilities, skills, spells, inventory, and everything else about this character." + text += "\n#renamecharacter new_name" + text += "\n Renames the character to the new name. All abilities, skills, inventory, etc. will remain the same. Quotes are not necessary." text += "\n#setclass class" text += "\n Sets the class of the character for player reference." text += "\n#setsummary summary" diff --git a/README.md b/README.md index 05cf4d2..0e9f1ff 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ See the [user guide here](https://github.com/raeleus/Hashtag-DnD/wiki). v. 0.1.0 * Added `#renameitem` to rename an existing item +* Added `#renamecharacter` to rename an existing character * Minor bug fixes and improvements v. 0.0.6