mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-06 05:30:28 -04:00
Added error checking to #initiative.
This commit is contained in:
parent
87019a3ae0
commit
619365344f
1 changed files with 15 additions and 3 deletions
18
Input.js
18
Input.js
|
@ -1708,16 +1708,28 @@ function doAddEnemy(command) {
|
|||
}
|
||||
|
||||
function doInitiative(command) {
|
||||
for (character of state.characters) {
|
||||
var battleHasStarted = state.initiativeOrder.length != 0
|
||||
|
||||
if (!battleHasStarted) for (character of state.characters) {
|
||||
var stat = character.stats.find(element => element.name.toLowerCase() == "dexterity")
|
||||
if (stat == null) character.initiative = calculateRoll("d20")
|
||||
else character.initiative = calculateRoll("d20") + getModifier(stat.value)
|
||||
}
|
||||
|
||||
createInitiativeOrder()
|
||||
if (state.enemies.length == 0) {
|
||||
state.show = "none"
|
||||
return "\n[Error: No enemies! Call #addenemy or #generateencounter]\n"
|
||||
}
|
||||
|
||||
if (!battleHasStarted) createInitiativeOrder()
|
||||
|
||||
if (state.initiativeOrder.length == 0) {
|
||||
state.show = "none"
|
||||
return "\n[Error: No combatants! Ensure that your characters have health and you have added enemies. See #help]\n"
|
||||
}
|
||||
|
||||
state.show = "initiative"
|
||||
return "\nBattle has commenced!\n"
|
||||
return battleHasStarted ? " " : "\nBattle has commenced!\n"
|
||||
}
|
||||
|
||||
function doTake(command) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue