mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-08-21 16:17:07 -04:00
Improved #heal to have parameters like #damage.
This commit is contained in:
parent
bc23453669
commit
be4f84816f
3 changed files with 58 additions and 16 deletions
67
Input.js
67
Input.js
|
@ -1532,21 +1532,62 @@ function doHeal(command) {
|
|||
state.show = "none"
|
||||
return "\n[Error: Not enough parameters. See #help]\n"
|
||||
}
|
||||
arg0 = parseInt(arg0)
|
||||
|
||||
var haveWord = character.name == "You" ? "have" : "has"
|
||||
var areWord = character.name == "You" ? "are" : "is"
|
||||
var arg1 = getArgumentRemainder(command, 1)
|
||||
|
||||
if (arg1 == null) {
|
||||
if (character == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Character must be specified. 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 haveWord = character.name == "You" ? "have" : "has"
|
||||
|
||||
character.health += healing
|
||||
character.health = clamp(character.health, 0, getHealthMax())
|
||||
|
||||
if (character.health >= getHealthMax()) {
|
||||
state.show = "none"
|
||||
return `\n[${character.name} ${areWord} at maximum health]\n`
|
||||
return `\n[${character.name} ${haveWord} been healed for ${healing} hp to a total of ${character.health}]\n`
|
||||
} else {
|
||||
var healing
|
||||
|
||||
var healingMatches = arg0.match(/\d*d\d+((\+|-)d+)?/gi)
|
||||
if (healingMatches != null) healing = calculateRoll(healingMatches[0])
|
||||
else {
|
||||
healingMatches = arg0.match(/\d+/g)
|
||||
log(healingMatches)
|
||||
if (healingMatches != null) healing = parseInt(healingMatches[0])
|
||||
}
|
||||
|
||||
if (healing == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Expected a number. See #help]\n"
|
||||
}
|
||||
|
||||
for (var enemy of state.enemies) {
|
||||
if (enemy.name.toLowerCase() == arg1.toLowerCase()) {
|
||||
enemy.health = Math.max(0, enemy.health + healing)
|
||||
return `\n[${toTitleCase(enemy.name)} has been healed for ${healing} hp to a total of ${enemy.health}]\n`
|
||||
}
|
||||
}
|
||||
|
||||
state.show = "none"
|
||||
return `\n[Error: Could not find an enemy matching the name ${enemy.name}. Type #enemies to see a list]`
|
||||
}
|
||||
|
||||
character.health = character.health + arg0
|
||||
character.health = clamp(character.health, 0, getHealthMax())
|
||||
|
||||
state.show = "none"
|
||||
return `\n[${character.name} ${haveWord} been healed by ${arg0} hp to ${character.health} health]\n`
|
||||
}
|
||||
|
||||
function doDamage(command) {
|
||||
|
@ -1585,7 +1626,7 @@ function doDamage(command) {
|
|||
character.health = clamp(character.health, 0, getHealthMax())
|
||||
|
||||
state.show = "none"
|
||||
return `\n[${character.name} ${haveWord} been damaged for ${damage} hp with ${character.health} remaining].${character.health == 0 ? " You are unconscious" : ""}\n`
|
||||
return `\n[${character.name} ${haveWord} been damaged for ${damage} hp with ${character.health} remaining] ${character.health == 0 ? " You are unconscious" : ""}\n`
|
||||
} else {
|
||||
var damage
|
||||
|
||||
|
@ -1605,7 +1646,7 @@ function doDamage(command) {
|
|||
for (var enemy of state.enemies) {
|
||||
if (enemy.name.toLowerCase() == arg1.toLowerCase()) {
|
||||
enemy.health = Math.max(0, enemy.health - damage)
|
||||
return `\n[${toTitleCase(enemy.name)} has been damaged for ${damage} hp with ${enemy.health} remaining].${enemy.health == 0 ? " " + toTitleCase(enemy.name) + " has been defeated!" : ""}\n`
|
||||
return `\n[${toTitleCase(enemy.name)} has been damaged for ${damage} hp with ${enemy.health} remaining] ${enemy.health == 0 ? " " + toTitleCase(enemy.name) + " has been defeated!" : ""}\n`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
text += "\n Increases the character's health by the 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 damage 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 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#setac value"
|
||||
text += "\n Sets the armor class of the character. The default is 10"
|
||||
text += "\n#setdamage value or dice_roll"
|
||||
|
|
|
@ -19,6 +19,7 @@ Watch the [tutorial video](https://youtu.be/E5TYU7rDaBQ).
|
|||
v. 0.2.2
|
||||
* Added Boss difficulty encounters
|
||||
* Added Humanoid Enemy Presets
|
||||
* Added optional enemy parameter to #heal
|
||||
* Minor bug fixes and improvements
|
||||
|
||||
v. 0.2.1 Hotfix 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue