Added #renamecharacter.

This commit is contained in:
raeleus 2024-09-29 09:10:53 -07:00
parent e4d58cd765
commit 9afe8b489e
3 changed files with 25 additions and 1 deletions

View file

@ -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)

View file

@ -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"

View file

@ -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