mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-08-20 22:17:07 -04:00
Added #block which reverses damage inflicted in the last turn in combat.
This commit is contained in:
parent
c4d292ca5a
commit
09bf0705ea
3 changed files with 37 additions and 3 deletions
35
Input.js
35
Input.js
|
@ -1,4 +1,4 @@
|
|||
const version = "Hashtag DnD v0.2.2"
|
||||
const version = "Hashtag DnD v0.3.0"
|
||||
const rollSynonyms = ["roll"]
|
||||
const createSynonyms = ["create", "generate", "start", "begin", "setup", "party", "member", "new"]
|
||||
const renameCharacterSynonyms = ["renamecharacter", "renameperson"]
|
||||
|
@ -80,6 +80,7 @@ const setupEnemySynonyms = ["setupenemy", "createenemy"]
|
|||
const setDamageSynonyms = ["setdamage"]
|
||||
const setProficiencySynonyms = ["setproficiency", "setweaponproficiency"]
|
||||
const healPartySynonyms = ["healparty", "healcharacters"]
|
||||
const blockSynonyms = ["block", "parry", "nullify", "invalidate"]
|
||||
const helpSynonyms = ["help"]
|
||||
|
||||
const modifier = (text) => {
|
||||
|
@ -128,7 +129,7 @@ const modifier = (text) => {
|
|||
return { text }
|
||||
}
|
||||
|
||||
if (!found) found = processCommandSynonyms(command, commandName, helpSynonyms.concat(rollSynonyms, noteSynonyms, eraseNoteSynonyms, showNotesSynonyms, clearNotesSynonyms, showCharactersSynonyms, removeCharacterSynonyms, generateNameSynonyms, setDefaultDifficultySynonyms, showDefaultDifficultySynonyms, renameCharacterSynonyms, cloneCharacterSynonyms, createLocationSynonyms, showLocationsSynonyms, goToLocationSynonyms, removeLocationSynonyms, getLocationSynonyms, clearLocationsSynonyms, goNorthSynonyms, goSouthSynonyms, goEastSynonyms, goWestSynonyms, encounterSynonyms, showEnemiesSynonyms, addEnemySynonyms, removeEnemySynonyms, clearEnemiesSynonyms, initiativeSynonyms, turnSynonyms, fleeSynonyms, versionSynonyms, setupEnemySynonyms, healSynonyms, damageSynonyms, restSynonyms, addExperienceSynonyms, healPartySynonyms, resetSynonyms), function () {return true})
|
||||
if (!found) found = processCommandSynonyms(command, commandName, helpSynonyms.concat(rollSynonyms, noteSynonyms, eraseNoteSynonyms, showNotesSynonyms, clearNotesSynonyms, showCharactersSynonyms, removeCharacterSynonyms, generateNameSynonyms, setDefaultDifficultySynonyms, showDefaultDifficultySynonyms, renameCharacterSynonyms, cloneCharacterSynonyms, createLocationSynonyms, showLocationsSynonyms, goToLocationSynonyms, removeLocationSynonyms, getLocationSynonyms, clearLocationsSynonyms, goNorthSynonyms, goSouthSynonyms, goEastSynonyms, goWestSynonyms, encounterSynonyms, showEnemiesSynonyms, addEnemySynonyms, removeEnemySynonyms, clearEnemiesSynonyms, initiativeSynonyms, turnSynonyms, fleeSynonyms, versionSynonyms, setupEnemySynonyms, healSynonyms, damageSynonyms, restSynonyms, addExperienceSynonyms, healPartySynonyms, blockSynonyms, resetSynonyms), function () {return true})
|
||||
|
||||
if (found == null) {
|
||||
if (state.characterName == null) {
|
||||
|
@ -223,6 +224,7 @@ const modifier = (text) => {
|
|||
if (text == null) text = processCommandSynonyms(command, commandName, setDamageSynonyms, doSetDamage)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, setProficiencySynonyms, doSetProficiency)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, healPartySynonyms, doHealParty)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, blockSynonyms, doBlock)
|
||||
if (text == null) text = processCommandSynonyms(command, commandName, helpSynonyms, doHelp)
|
||||
if (text == null) {
|
||||
var character = getCharacter()
|
||||
|
@ -1973,6 +1975,9 @@ function doAttack(command) {
|
|||
if (score == 20 || score + modifier >= targetRoll) {
|
||||
if (score == 20) enemyString += `\nCritical Damage: ${damage}\n`
|
||||
else enemyString += `\nDamage: ${damage}\n`
|
||||
|
||||
state.blockCharacter = foundEnemy
|
||||
state.blockPreviousHealth = foundEnemy.health
|
||||
foundEnemy.health = Math.max(0, foundEnemy.health - damage)
|
||||
if (foundEnemy.health == 0) {
|
||||
enemyString += ` ${toTitleCase(foundEnemy.name)} has been defeated!`
|
||||
|
@ -2610,6 +2615,8 @@ function doTurn(command) {
|
|||
var text = `\n[It is ${possessiveName} turn]\n`
|
||||
if (getRandomBoolean() || activeCharacter.spells.length == 0) {
|
||||
if (hit) {
|
||||
state.blockCharacter = target
|
||||
state.blockPreviousHealth = target.health
|
||||
var damage = isNaN(activeCharacter.damage) ? calculateRoll(activeCharacter.damage) : activeCharacter.damage
|
||||
target.health = Math.max(target.health - damage, 0)
|
||||
|
||||
|
@ -2642,6 +2649,27 @@ function doTurn(command) {
|
|||
}
|
||||
}
|
||||
|
||||
function doBlock(command) {
|
||||
if (state.blockCharacter == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: No attack to block. See #help]\n"
|
||||
}
|
||||
|
||||
var character = state.characters.find(x => x.name.toLowerCase() == state.blockCharacter.name.toLowerCase())
|
||||
if (character == null) character = state.enemies.find(x => x.name.toLowerCase() == state.blockCharacter.name.toLowerCase())
|
||||
if (character == null) {
|
||||
state.show = "none"
|
||||
return "\n[Error: Character no longer exists. See #help]\n"
|
||||
}
|
||||
|
||||
character.health = state.blockPreviousHealth
|
||||
|
||||
var properName = toTitleCase(character.name)
|
||||
state.show = "prefix"
|
||||
state.prefix = `[${properName} has ${character.health} health]`
|
||||
return `\nHowever, the damage to ${properName} was blocked!\n`
|
||||
}
|
||||
|
||||
function doTake(command) {
|
||||
var itemIndex = 0
|
||||
var arg0 = getArgument(command, 0)
|
||||
|
@ -3195,6 +3223,9 @@ function doCastSpell(command) {
|
|||
if (roll == 20 || roll + modifier >= difficulty) {
|
||||
if (roll == 20) enemyString += `\nCritical Damage: ${damage}\n`
|
||||
else enemyString += `\nDamage: ${damage}\n`
|
||||
|
||||
state.blockCharacter = foundEnemy
|
||||
state.blockPreviousHealth = foundEnemy.health
|
||||
foundEnemy.health = Math.max(0, foundEnemy.health - damage)
|
||||
if (foundEnemy.health == 0) enemyString += ` ${toTitleCase(foundEnemy.name)} has been defeated!\n`
|
||||
else enemyString += ` ${toTitleCase(foundEnemy.name)} has ${foundEnemy.health} health remaining!\n`
|
||||
|
|
|
@ -469,6 +469,8 @@ const modifier = (text) => {
|
|||
text += "\n Assigns initiative to all characters and enemies. 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#block"
|
||||
text += "\n Reverses the damage that has been inflicted in the last turn. This applies to damage on characters and enemies."
|
||||
text += "\n#flee (difficulty_class or automatic|effortless|easy|medium|hard|impossible)"
|
||||
text += "\n Attempt to flee from combat. If the difficulty is not specified, the default difficulty will be used instead."
|
||||
|
||||
|
|
|
@ -16,11 +16,12 @@ Create locations to travel to and view them in a map
|
|||
See the [user guide here](https://github.com/raeleus/Hashtag-DnD/wiki).
|
||||
Watch the [tutorial video](https://youtu.be/E5TYU7rDaBQ).
|
||||
|
||||
v. 0.2.2
|
||||
v. 0.3.0
|
||||
* Added Boss difficulty encounters
|
||||
* Added Humanoid Enemy Presets
|
||||
* Added optional enemy parameter to #heal
|
||||
* Added #healparty
|
||||
* Added #block which reverses damage inflicted in the last turn in combat
|
||||
* Tweaked #heal and #damage to allow targeting characters specified as a parameter
|
||||
* Fixed defeated enemies not being removed from combat
|
||||
* Minor bug fixes and improvements
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue