diff --git a/Input.js b/Input.js index d370879..1585e49 100644 --- a/Input.js +++ b/Input.js @@ -127,7 +127,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, 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, resetSynonyms), function () {return true}) if (found == null) { if (state.characterName == null) { @@ -1585,8 +1585,16 @@ function doHeal(command) { } } + for (var character of state.characters) { + if (character.name.toLowerCase() == arg1.toLowerCase()) { + character.health += healing + character.health = clamp(character.health, 0, getHealthMax(character)) + return `\n[${toTitleCase(character.name)} has been healed for ${healing} hp to a total of ${character.health}]\n` + } + } + state.show = "none" - return `\n[Error: Could not find an enemy matching the name ${enemy.name}. Type #enemies to see a list]` + return `\n[Error: Could not find an enemy or character matching the name ${arg1}. Type #enemies or #characters to see a list]` } } @@ -1650,8 +1658,15 @@ function doDamage(command) { } } + for (var character of state.characters) { + if (character.name.toLowerCase() == arg1.toLowerCase()) { + character.health = Math.max(0, character.health - damage) + return `\n[${toTitleCase(character.name)} has been damaged for ${damage} hp with ${character.health} remaining] ${character.health == 0 ? " " + toTitleCase(character.name) + " is unconcious!" : ""}\n` + } + } + state.show = "none" - return `\n[Error: Could not find an enemy matching the name ${enemy.name}. Type #enemies to see a list]` + return `\n[Error: Could not find an enemy matching the name ${arg1}. Type #enemies or #characters to see a list]` } } diff --git a/Output.js b/Output.js index 9922fdf..d513131 100644 --- a/Output.js +++ b/Output.js @@ -352,10 +352,10 @@ const modifier = (text) => { text += "\n Sets the summary of the character for player reference. Quotes are not necessary." text += "\n#sethealth value" 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 (enemy)" - text += "\n Increases the enemy's health by the specified value or dice_roll. If an enemy isn't specified, the character calling the command is healed." - text += "\n#damage value or dice_roll (enemy) " - text += "\n Decreases the enemy's health by the specified value or dice_roll. If an enemy isn't specified, the character calling the command is damaged. Reaching 0 causes the character to become \"unconscious\"." + 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#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" text += "\n Sets the armor class of the character. The default is 10" text += "\n#setdamage value or dice_roll" diff --git a/README.md b/README.md index 6921a5b..2101b66 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 +* Tweaked #heal and #damage to allow targeting characters specified as a parameter * Minor bug fixes and improvements v. 0.2.1 Hotfix 1