mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-05 13:10:28 -04:00
Added #flee
This commit is contained in:
parent
619365344f
commit
f855683de8
2 changed files with 36 additions and 2 deletions
34
Input.js
34
Input.js
|
@ -206,6 +206,7 @@ const modifier = (text) => {
|
|||
if (text == null) text = processCommandSynonyms(command, commandName, clearEnemiesSynonyms, doClearEnemies)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, addEnemySynonyms, doAddEnemy)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, initiativeSynonyms, doInitiative)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, fleeSynonyms, doFlee)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, helpSynonyms, doHelp)
|
||||
if (text == null) {
|
||||
var character = getCharacter()
|
||||
|
@ -1732,6 +1733,39 @@ function doInitiative(command) {
|
|||
return battleHasStarted ? " " : "\nBattle has commenced!\n"
|
||||
}
|
||||
|
||||
function doFlee(command) {
|
||||
if (state.initiativeOrder.length == 0) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Not in combat. Call #initiative first]\n"
|
||||
}
|
||||
|
||||
var difficulty = getArgument(command, 0)
|
||||
if (difficulty != null) {
|
||||
const difficultyNames = ["impossible", "extreme", "hard", "medium", "easy", "effortless", "automatic"]
|
||||
const difficultyScores = [30, 25, 20, 15, 10, 5, 0]
|
||||
|
||||
const difficultyPatternNames = [...new Set(difficultyNames)]
|
||||
difficultyPatternNames.push("\\d+")
|
||||
var difficultyIndex = difficultyNames.indexOf(difficulty)
|
||||
if (difficultyIndex >= 0 && difficultyIndex < difficultyNames.length) {
|
||||
difficulty = difficultyScores[difficultyIndex]
|
||||
}
|
||||
} else {
|
||||
difficulty = state.defaultDifficulty
|
||||
}
|
||||
|
||||
var roll = calculateRoll("d20")
|
||||
|
||||
var text = ""
|
||||
if (difficulty != 0) text += `\n[DC: ${difficulty} Roll: ${roll}]\n`
|
||||
if (roll >= difficulty) {
|
||||
state.initiativeOrder = []
|
||||
text += `\nThe party successfuly flees from battle!\n`
|
||||
} else text += `\nThe party tries to flee from battle, but fails!\n`
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
function doTake(command) {
|
||||
var arg0 = getArgument(command, 0)
|
||||
if (arg0 == null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue