mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-05 21:20:27 -04:00
Show the result of attack rolls. Resolves #78
This commit is contained in:
parent
23ddbf0109
commit
a8d586cf06
1 changed files with 7 additions and 1 deletions
8
Input.js
8
Input.js
|
@ -2565,13 +2565,17 @@ function doTurn(command) {
|
|||
var target = characters[getRandomInteger(0, characters.length - 1)]
|
||||
var areWord = target.name == "You" ? "are" : "is"
|
||||
var targetNameAdjustedCase = target.name == "You" ? "you" : toTitleCase(target.name)
|
||||
var hit = calculateRoll(`1d20${activeCharacter.hitModifier > 0 ? "+" + activeCharacter.hitModifier : activeCharacter.hitModifier < 0 ? activeCharacter.hitModifier : ""}`) >= target.ac
|
||||
var attack = calculateRoll(`1d20${activeCharacter.hitModifier > 0 ? "+" + activeCharacter.hitModifier : activeCharacter.hitModifier < 0 ? activeCharacter.hitModifier : ""}`)
|
||||
var hit = attack >= target.ac
|
||||
|
||||
var text = `\n[It is ${possessiveName} turn]\n`
|
||||
if (getRandomBoolean() || activeCharacter.spells.length == 0) {
|
||||
if (hit) {
|
||||
var damage = isNaN(activeCharacter.damage) ? calculateRoll(activeCharacter.damage) : activeCharacter.damage
|
||||
target.health = Math.max(target.health - damage, 0)
|
||||
|
||||
text += `\n[Character AC: ${target.ac} Attack roll: ${attack}]\n`
|
||||
|
||||
text += `${activeCharacterName} attacks ${targetNameAdjustedCase} for ${damage} damage!\n`
|
||||
if (target.health == 0) text += ` ${toTitleCase(target.name)} ${areWord} unconscious! \n`
|
||||
else text += ` ${toTitleCase(target.name)} ${areWord} at ${target.health} health.\n`
|
||||
|
@ -2586,6 +2590,8 @@ function doTurn(command) {
|
|||
var spell = spell.substring(0, spell.length - diceMatches[0].length)
|
||||
target.health = Math.max(target.health - damage, 0)
|
||||
|
||||
text += `\n[Character AC: ${target.ac} Attack roll: ${attack}]\n`
|
||||
|
||||
text += `${activeCharacterName} casts spell ${spell} at ${targetNameAdjustedCase} for ${damage} damage!`
|
||||
|
||||
if (target.health == 0) text += ` ${toTitleCase(target.name)} ${areWord} unconscious!\n`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue