diff --git a/Input.js b/Input.js index c231059..32a46c2 100644 --- a/Input.js +++ b/Input.js @@ -79,6 +79,7 @@ const versionSynonyms = ["version", "ver", "showversion"] const setupEnemySynonyms = ["setupenemy", "createenemy"] const setDamageSynonyms = ["setdamage"] const setProficiencySynonyms = ["setproficiency", "setweaponproficiency"] +const healPartySynonyms = ["healparty", "healcharacters"] const helpSynonyms = ["help"] const modifier = (text) => { @@ -127,7 +128,7 @@ const modifier = (text) => { 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, healSynonyms, damageSynonyms, restSynonyms, addExperienceSynonyms, 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, healSynonyms, damageSynonyms, restSynonyms, addExperienceSynonyms, healPartySynonyms, resetSynonyms), function () {return true}) if (found == null) { if (state.characterName == null) { @@ -221,6 +222,7 @@ const modifier = (text) => { if (text == null) text = processCommandSynonyms(command, commandName, setupEnemySynonyms, doSetupEnemy) if (text == null) text = processCommandSynonyms(command, commandName, setDamageSynonyms, doSetDamage) if (text == null) text = processCommandSynonyms(command, commandName, setProficiencySynonyms, doSetProficiency) + if (text == null) text = processCommandSynonyms(command, commandName, healPartySynonyms, doHealParty) if (text == null) text = processCommandSynonyms(command, commandName, helpSynonyms, doHelp) if (text == null) { var character = getCharacter() @@ -1696,6 +1698,37 @@ function doRest(command) { return text } +function doHealParty(command) { + var arg0 = getArgument(command, 0) + if (arg0 == null) { + state.show = "none" + return "\n[Error: Not enough parameters. See #help]\n" + } + + var healing + var healingMatches = arg0.match(/\d*d\d+((\+|-)d+)?/gi) + if (healingMatches != null) healing = calculateRoll(healingMatches[0]) + else { + healingMatches = arg0.match(/\d+/g) + if (healingMatches != null) healing = parseInt(healingMatches[healingMatches.length - 1]) + } + + if (healing == null) { + state.show = "none" + return "\n[Error: Expected a number. See #help]\n" + } + + var text = `\n[All characters have been healed by ${healing}.]\n` + state.characters.forEach(function(character) { + var max = getHealthMax(character) + character.health += healing + if (character.health > max) character.health = max + text += `[${toTitleCase(character.name)}: ${character.health} / ${max} health]\n` + }) + state.show = "none" + return text +} + function doFlipCommandAbility(command) { var ability = getCommandName(command) var arg0 = getArgument(command, 0) diff --git a/Output.js b/Output.js index d513131..ea401bd 100644 --- a/Output.js +++ b/Output.js @@ -354,6 +354,8 @@ const modifier = (text) => { text += "\n Sets the character's health to specified value. It's capped at the character's max health." text += "\n#heal value or dice_roll (target)" text += "\n Increases the target enemy's or character's health by the specified value or dice_roll. If a target isn't specified, the character calling the command is healed." + text += "\n#healparty value or dice_roll" + text += "\n Increases the health of all party characters' by the specified value or dice_roll." text += "\n#damage value or dice_roll (target) " text += "\n Decreases the target enemy's or character's health by the specified value or dice_roll. If a target isn't specified, the character calling the command is damaged. Reaching 0 causes the target to become \"unconscious\"." text += "\n#setac value" diff --git a/README.md b/README.md index 3b49b91..eb7c3da 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ v. 0.2.2 * Added Boss difficulty encounters * Added Humanoid Enemy Presets * Added optional enemy parameter to #heal +* Added #healparty * Tweaked #heal and #damage to allow targeting characters specified as a parameter * Fixed defeated enemies not being removed from combat * Minor bug fixes and improvements