mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-05 13:10:28 -04:00
Added #clonecharacter.
This commit is contained in:
parent
9afe8b489e
commit
0d6d80e6c0
4 changed files with 42 additions and 2 deletions
24
Input.js
24
Input.js
|
@ -1,7 +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 cloneCharacterSynonyms = ["clone", "clonecharacter", "cloneperson", "copycharacter", "copyperson", "duplicatecharacter", "duplicateperson", "dupecharacter", "dupeperson"]
|
||||
const bioSynonyms = ["bio", "biography", "summary", "character", "charactersheet", "statsheet"]
|
||||
const setClassSynonyms = ["setclass", "class"]
|
||||
const setSummarySynonyms = ["setsummary", "summary"]
|
||||
|
@ -151,7 +151,7 @@ const modifier = (text) => {
|
|||
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, cloneCharacterSynonyms, doCloneCharacter)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, helpSynonyms, doHelp)
|
||||
if (text == null) {
|
||||
var character = getCharacter()
|
||||
|
@ -590,6 +590,26 @@ function doRenameCharacter(command) {
|
|||
return text
|
||||
}
|
||||
|
||||
function doCloneCharacter(command) {
|
||||
var character = getCharacter()
|
||||
var possessiveName = getPossessiveName(character.name)
|
||||
|
||||
var arg0 = getArgumentRemainder(command, 0)
|
||||
if (arg0 == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Not enough parameters. See #help]\n"
|
||||
}
|
||||
|
||||
if (!hasCharacter(arg0)) createCharacter(arg0)
|
||||
var newCharacter = getCharacter(arg0)
|
||||
copyCharacter(character, newCharacter)
|
||||
|
||||
state.show = "none"
|
||||
var text = `\n[${character.name} has been cloned to a new character called ${newCharacter.name}]\n`
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
function doSetStat(command) {
|
||||
var character = getCharacter()
|
||||
var arg0 = getArgument(command, 0)
|
||||
|
|
17
Library.js
17
Library.js
|
@ -218,6 +218,23 @@ function createCharacter(name) {
|
|||
return character
|
||||
}
|
||||
|
||||
function copyCharacter(fromCharacter, toCharacter) {
|
||||
if (toCharacter != null && fromCharacter != null) {
|
||||
toCharacter.className = fromCharacter.className
|
||||
toCharacter.summary = fromCharacter.summary
|
||||
toCharacter.inventory = [...new Set(fromCharacter.inventory)]
|
||||
toCharacter.spells = [...new Set(fromCharacter.spells)]
|
||||
toCharacter.stats = [...new Set(fromCharacter.stats)]
|
||||
toCharacter.spellStat = fromCharacter.spellStat
|
||||
toCharacter.meleeStat = fromCharacter.meleeStat
|
||||
toCharacter.rangedStat = fromCharacter.rangedStat
|
||||
toCharacter.skills = [...new Set(fromCharacter.skills)]
|
||||
toCharacter.experience = fromCharacter.experience
|
||||
toCharacter.health = fromCharacter.health
|
||||
return toCharacter
|
||||
}
|
||||
}
|
||||
|
||||
function deleteCharacter(name) {
|
||||
var index = state.characters.findIndex((element) => element.name == name)
|
||||
state.characters.splice(index, 1)
|
||||
|
|
|
@ -207,6 +207,8 @@ const modifier = (text) => {
|
|||
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#clonecharacter new_name"
|
||||
text += "\n Copies the abilities, skills, inventory, etc. of the current character to a new character with the name new_name. Quotes are not necessary."
|
||||
text += "\n#setclass class"
|
||||
text += "\n Sets the class of the character for player reference."
|
||||
text += "\n#setsummary summary"
|
||||
|
|
|
@ -17,6 +17,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
|
||||
* Added `#clonecharacter` to copy an existing character
|
||||
* Minor bug fixes and improvements
|
||||
|
||||
v. 0.0.6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue