#xp now has a parameter for party and it displays how much xp you need for the next level. Resolves #68

This commit is contained in:
raeleus 2024-10-14 07:34:57 -07:00
parent 8b199345e9
commit 3a25a8697a
3 changed files with 38 additions and 14 deletions

View file

@ -123,16 +123,16 @@ const modifier = (text) => {
if (state.characterName == null && found) {
state.show = "none"
text = `\n[Error: Character name not specified. Use the "do" or "say" modes. Alternatively, use "story" mode with the following format without quotes: "charactername #hashtag"]\n`
text = `\n[Error: Character name not specified. Use the "do" or "say" modes. Alternatively, use "story" mode in the following format without quotes: "charactername #hashtag"]\n`
return { text }
}
if (!found) found = processCommandSynonyms(command, commandName, helpSynonyms.concat(rollSynonyms, noteSynonyms, eraseNoteSynonyms, showNotesSynonyms, clearNotesSynonyms, showCharactersSynonyms, removeCharacterSynonyms, generateNameSynonyms, setDefaultDifficultySynonyms, showDefaultDifficultySynonyms, renameCharacterSynonyms, cloneCharacterSynonyms, createLocationSynonyms, showLocationsSynonyms, goToLocationSynonyms, removeLocationSynonyms, getLocationSynonyms, clearLocationsSynonyms, goNorthSynonyms, goSouthSynonyms, goEastSynonyms, goWestSynonyms, encounterSynonyms, showEnemiesSynonyms, addEnemySynonyms, removeEnemySynonyms, clearEnemiesSynonyms, initiativeSynonyms, turnSynonyms, fleeSynonyms, versionSynonyms, setupEnemySynonyms, damageSynonyms, restSynonyms, resetSynonyms), function () {return true})
if (!found) found = processCommandSynonyms(command, commandName, helpSynonyms.concat(rollSynonyms, noteSynonyms, eraseNoteSynonyms, showNotesSynonyms, clearNotesSynonyms, showCharactersSynonyms, removeCharacterSynonyms, generateNameSynonyms, setDefaultDifficultySynonyms, showDefaultDifficultySynonyms, renameCharacterSynonyms, cloneCharacterSynonyms, createLocationSynonyms, showLocationsSynonyms, goToLocationSynonyms, removeLocationSynonyms, getLocationSynonyms, clearLocationsSynonyms, goNorthSynonyms, goSouthSynonyms, goEastSynonyms, goWestSynonyms, encounterSynonyms, showEnemiesSynonyms, addEnemySynonyms, removeEnemySynonyms, clearEnemiesSynonyms, initiativeSynonyms, turnSynonyms, fleeSynonyms, versionSynonyms, setupEnemySynonyms, damageSynonyms, restSynonyms, addExperienceSynonyms, resetSynonyms), function () {return true})
if (found == null) {
if (state.characterName == null) {
state.show = "none"
text = `\n[Error: Character name not specified. Use the "do" or "say" modes. Alternatively, use "story" mode with the following format without quotes: "charactername #hashtag"]\n`
text = `\n[Error: Character name not specified. Use the "do" or "say" modes. Alternatively, use "story" mode in the following format without quotes: "charactername #hashtag"]\n`
return { text }
} else {
state.show = "none"
@ -1282,21 +1282,41 @@ function doAddExperience(command) {
state.show = "none"
return "\n[Error: Not enough parameters. See #help]\n"
}
arg0 = searchArgument(command, /\d+/gi)
if (arg0 == null) {
state.show = "none"
return "\n[Error: Expected a number. See #help]\n"
}
arg0 = parseInt(arg0)
var possessiveName = getPossessiveName(character.name)
var arg1 = searchArgument(command, /party/gi)
var level = getLevel(character.experience)
character.experience += arg0
var newLevel = getLevel(character.experience)
if (newLevel > level) {
if (arg1 == null && character == null) {
state.show = "none"
return `\n[${possessiveName} experience is increased to ${character.experience}. LEVEL UP! Level: ${newLevel}, Health Max: ${getHealthMax()}]\n`
return `\n[Error: Character name not specified. Use the "do" or "say" modes. Alternatively, use "story" mode in the following format without quotes: "charactername #hashtag"]\n`
}
state.show = "none"
return `\n[${possessiveName} experience is increased to ${character.experience}]\n`
if (state.characters.length == 0) {
state.show = "none"
return `\n[Error: There are no characters. Type #setup to create a character]\n`
}
state.prefix = "\n"
characters = arg1 == null ? [character] : state.characters
for (var c of characters) {
var possessiveName = getPossessiveName(c.name)
var level = getLevel(c.experience)
c.experience += arg0
var newLevel = getLevel(c.experience)
if (newLevel > level) state.prefix += `[${possessiveName} experience is increased to ${c.experience}. LEVEL UP! Level: ${newLevel}, Health Max: ${getHealthMax(c)}. Next level at ${getNextLevelXp(c.experience)}]\n`
else state.prefix += `[${possessiveName} experience is increased to ${c.experience}. Next level at ${getNextLevelXp(c.experience)}]\n`
}
state.show = "prefixOnly"
return " "
}
function doLevelUp(command) {

View file

@ -276,6 +276,9 @@ const modifier = (text) => {
case "prefix":
text = state.prefix + originalText
break
case "prefixOnly":
text = state.prefix
break
case "clearInventory":
text += `[${possessiveName} inventory has been emptied]\n`
break
@ -367,8 +370,8 @@ const modifier = (text) => {
text += "\n Sets the number of days since your adventure began."
text += "\n#setxp value"
text += "\n Sets the character's experience to the specified value."
text += "\n#addxp value"
text += "\n Increases the character's experience by the specified value. The player is notified if there is a level up."
text += "\n#addxp (party) value"
text += "\n Increases the character's experience by the specified value. The player is notified if there is a level up. If the parameter party is specified, xp will be added to the entire party instead. Parameters can be listed in any order."
text += "\n#setautoxp value"
text += "\n Automatically increases the experience of all party members when a #try, #attack, or #cast is called. The amount of experience is scaled based on the difficulty class of the check with any check 20 or higher will result in the maximum specified by value. Set to 0 to disable."
text += "\n#showautoxp"

View file

@ -17,6 +17,7 @@ See the [user guide here](https://github.com/raeleus/Hashtag-DnD/wiki).
Watch the [tutorial video](https://youtu.be/E5TYU7rDaBQ).
v. 0.2.1
* Call `#xp` with the parameter `party` to add xp to the entire group
* Added places of interest to `#location`
* Minor bug fixes and improvements