mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-05 13:10:28 -04:00
Added #addenemy
This commit is contained in:
parent
129f063f35
commit
f5433ec6f8
2 changed files with 70 additions and 3 deletions
67
Input.js
67
Input.js
|
@ -204,6 +204,7 @@ const modifier = (text) => {
|
|||
if (text == null) text = processCommandSynonyms(command, commandName, showEnemiesSynonyms, doShowEnemies)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, removeEnemySynonyms, doRemoveEnemy)
|
||||
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, helpSynonyms, doHelp)
|
||||
if (text == null) {
|
||||
var character = getCharacter()
|
||||
|
@ -1638,6 +1639,72 @@ function doClearEnemies(command) {
|
|||
return "\n[The enemies have been cleared]\n"
|
||||
}
|
||||
|
||||
function doAddEnemy(command) {
|
||||
var name = getArgument(command, 0)
|
||||
if (name == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Not enough parameters. See #help]\n"
|
||||
}
|
||||
|
||||
var health = getArgument(command, 1)
|
||||
if (health == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Not enough parameters. See #help]\n"
|
||||
} else if (/^\d*d\d+((\+|-)\d+)?$/g.test(health)) {
|
||||
health = calculateRoll(health)
|
||||
} else if (isNaN(health)) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Expected a number. See #help]\n"
|
||||
}
|
||||
health = parseInt(health)
|
||||
|
||||
var ac = getArgument(command, 2)
|
||||
if (ac == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Not enough parameters. See #help]\n"
|
||||
} else if (/^\d*d\d+((\+|-)\d+)?$/g.test(ac)) {
|
||||
ac = calculateRoll(ac)
|
||||
} else if (isNaN(ac)) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Expected a number. See #help]\n"
|
||||
}
|
||||
ac = parseInt(ac)
|
||||
|
||||
var damage = getArgument(command, 3)
|
||||
if (damage == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Not enough parameters. See #help]\n"
|
||||
} else if (isNaN(damage) && !/^\d*d\d+((\+|-)\d+)?$/g.test(damage)) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Expected a number. See #help]\n"
|
||||
}
|
||||
|
||||
var initiative = getArgument(command, 4)
|
||||
if (initiative == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Not enough parameters. See #help]\n"
|
||||
} else if (/^\d*d\d+((\+|-)\d+)?$/g.test(initiative)) {
|
||||
initiative = calculateRoll(initiative)
|
||||
} else if (isNaN(initiative)) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Expected a number. See #help]\n"
|
||||
}
|
||||
initiative = parseInt(initiative)
|
||||
|
||||
var spells = []
|
||||
var spell = null
|
||||
var index = 5
|
||||
do {
|
||||
spell = getArgument(command, index++)
|
||||
if (spell != null) spells.push(spell)
|
||||
} while (spell != null)
|
||||
|
||||
var enemy = createEnemy(name, health, ac, damage, initiative, spells)
|
||||
state.enemies.push(enemy)
|
||||
|
||||
return `[Enemy ${enemy.name} has been created]`
|
||||
}
|
||||
|
||||
function doTake(command) {
|
||||
var arg0 = getArgument(command, 0)
|
||||
if (arg0 == null) {
|
||||
|
|
|
@ -365,12 +365,12 @@ const modifier = (text) => {
|
|||
text += "\n Generate an encounter from the specified list. If a list is not specified, it will default to \"easy\" You can instead provide a number as a challenge rating which will scale encounters from the appropriate list."
|
||||
text += "\n#showenemies"
|
||||
text += "\n Shows the list of current enemies."
|
||||
text += "\n#addenemy (ac) (damage_modifier) name"
|
||||
text += "\n Adds the specified enemy to the list of enemies. It will automatically be assigned an inititiative. You can specify an armor class or both an armor class and damage modifier."
|
||||
text += "\n#addenemy name health ac damage initiative spells"
|
||||
text += "\n Adds the specified enemy to the list of enemies. health, ac, damage, and initiative can be numbers or dice rolls such as 3d6+5. Type the name in quotes if the name contains a space. The rest of the parameters can be a list of spells. Each spell must be typed in quotes if it has a space. If the spell does damage, write the name and damage roll in the following format: \"Ray of Frost5d10\""
|
||||
text += "\n#removeenemy name or index"
|
||||
text += "\n Removes the enemy as specified by the name or index. To delete multiple enemies, type the numbers with spaces or commas between them. This is safer than calling #removenote multiple times because the numbers shift as enemies are deleted. Quotes are not necessary."
|
||||
text += "\n#initiative"
|
||||
text += "\n Assigns initiative to all characters and enemies. This begins combat."
|
||||
text += "\n Assigns initiative to all characters. This begins combat."
|
||||
text += "\n#turn"
|
||||
text += "\n Updates the turn to the next character in combat. If it is an enemy, the enemy will attack. If it's a player character, the system will allow the player to take their turn. If there are no enemies left or all the player characters are dead, combat ends."
|
||||
text += "\n#flee (dc or automatic|effortless|easy|)"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue