mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-05 05:00:26 -04:00
Fixed defeated enemies not being removed from combat. Resolves #92
This commit is contained in:
parent
457d7439a1
commit
e13e65a37c
2 changed files with 8 additions and 7 deletions
14
Input.js
14
Input.js
|
@ -1569,7 +1569,6 @@ function doHeal(command) {
|
|||
if (healingMatches != null) healing = calculateRoll(healingMatches[0])
|
||||
else {
|
||||
healingMatches = arg0.match(/\d+/g)
|
||||
log(healingMatches)
|
||||
if (healingMatches != null) healing = parseInt(healingMatches[0])
|
||||
}
|
||||
|
||||
|
@ -1642,7 +1641,6 @@ function doDamage(command) {
|
|||
if (damageMatches != null) damage = calculateRoll(damageMatches[0])
|
||||
else {
|
||||
damageMatches = arg0.match(/\d+/g)
|
||||
log(damageMatches)
|
||||
if (damageMatches != null) damage = parseInt(damageMatches[0])
|
||||
}
|
||||
|
||||
|
@ -1918,7 +1916,6 @@ function doAttack(command) {
|
|||
var indexMatches = targetText.match(/(?<=enemy\s*)\d+/gi)
|
||||
if (indexMatches != null) {
|
||||
foundEnemy = state.enemies[parseInt(indexMatches[0]) - 1]
|
||||
log(`foundEnemy:${foundEnemy}`)
|
||||
targetText = targetText.replace(/enemy\s*d+/gi, foundEnemy.name)
|
||||
}
|
||||
}
|
||||
|
@ -1940,8 +1937,10 @@ function doAttack(command) {
|
|||
if (score == 20) enemyString += `\nCritical Damage: ${damage}\n`
|
||||
else enemyString += `\nDamage: ${damage}\n`
|
||||
foundEnemy.health = Math.max(0, foundEnemy.health - damage)
|
||||
if (foundEnemy.health == 0) enemyString += ` ${toTitleCase(foundEnemy.name)} has been defeated!`
|
||||
else enemyString += ` ${toTitleCase(foundEnemy.name)} has ${foundEnemy.health} health remaining!`
|
||||
if (foundEnemy.health == 0) {
|
||||
enemyString += ` ${toTitleCase(foundEnemy.name)} has been defeated!`
|
||||
|
||||
} else enemyString += ` ${toTitleCase(foundEnemy.name)} has ${foundEnemy.health} health remaining!`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2524,7 +2523,8 @@ function doTurn(command) {
|
|||
if (enemy.health > 0) continue
|
||||
|
||||
defeatedEnemies++
|
||||
var index = state.initiativeOrder.indexOf(enemy)
|
||||
var index = state.initiativeOrder.findIndex(x => x.name.toLowerCase() == enemy.name.toLowerCase())
|
||||
log(`index:${index}`)
|
||||
if (index >= 0) state.initiativeOrder.splice(index, 1)
|
||||
}
|
||||
|
||||
|
@ -2533,7 +2533,7 @@ function doTurn(command) {
|
|||
if (character.health > 0) continue
|
||||
|
||||
defeatedCharacters++
|
||||
var index = state.initiativeOrder.indexOf(character)
|
||||
var index = state.initiativeOrder.findIndex(x => x.name.toLowerCase() == character.name.toLowerCase())
|
||||
if (index >= 0) state.initiativeOrder.splice(index, 1)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue