Skip to content

Commit

Permalink
Exhaustion, Tools, Versions
Browse files Browse the repository at this point in the history
- Exhaustion: Add Exhaustion group and action.
- Tools: Exclude tools from requirement for activation costs.
- Versions: Update verified versions.
  • Loading branch information
Larkinabout committed Sep 17, 2023
1 parent 62f5d14 commit c353d00
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
# Create a "module.zip" archive containing all the module's required files.
# If you have other directories or files that will need to be added to
# your packaged module, add them here.
- run: zip -r ./module.zip module.json readme.md LICENSE languages/ scripts/token-action-hud-dnd5e.min.js styles/
- run: zip -r ./module.zip module.json readme.md LICENSE icons/ languages/ scripts/token-action-hud-dnd5e.min.js styles/

# Update the GitHub release with the manifest and module archive files.
- name: Update Release with Files
Expand Down
1 change: 1 addition & 0 deletions icons/exhaustion.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": "This is auto replaced",
"compatibility": {
"minimum": "10",
"verified": "11.307"
"verified": "11.308"
},
"esmodules": [
"./scripts/token-action-hud-dnd5e.min.js"
Expand Down Expand Up @@ -90,7 +90,7 @@
"compatibility": [
{
"minimum": "2.1.0",
"verified": "2.2.3"
"verified": "2.3.1"
}
]
}
Expand All @@ -103,7 +103,7 @@
{
"minimum": "1.4.8",
"maximum": "1.4",
"verified": "1.4.18"
"verified": "1.4.19"
}
]
}
Expand Down
45 changes: 44 additions & 1 deletion scripts/action-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
this.#buildAbilities('check', 'checks')
this.#buildAbilities('save', 'saves')
this.#buildCombat()
this.#buildExhaustion()
this.#buildRests()
this.#buildSkills()
this.#buildUtility()
Expand Down Expand Up @@ -450,6 +451,48 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
])
}

/**
* Build exhaustion
* @private
*/
#buildExhaustion () {
// Exit if every actor is not the character type
if (this.actors.length === 0) return
if (!this.actors.every(actor => actor.type === 'character')) return

const actionType = 'exhaustion'

const id = 'exhaustion'
const name = coreModule.api.Utils.i18n('DND5E.Exhaustion')
const actionTypeName = `${coreModule.api.Utils.i18n(ACTION_TYPE[actionType])}: ` ?? ''
const listName = `${actionTypeName}${name}`
const encodedValue = [actionType, id].join(this.delimiter)
const img = coreModule.api.Utils.getImage('modules/token-action-hud-dnd5e/icons/exhaustion.svg')
const info1 = { text: this.actor.system.attributes.exhaustion }
let cssClass = ''
const active = this.actor.system.attributes.exhaustion > 0
? ' active'
: ''
cssClass = `toggle${active}`

// Get actions
const actions = [{
cssClass,
id,
name,
encodedValue,
img,
info1,
listName
}]

// Create group data
const groupData = { id: 'exhaustion', type: 'system' }

// Add actions to HUD
this.addActions(actions, groupData)
}

/**
* Build features
* @private
Expand Down Expand Up @@ -1042,7 +1085,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
const activationTypes = Object.keys(game.dnd5e.config.abilityActivationTypes).filter((at) => at !== 'none')
const activation = item.system.activation
const activationType = activation?.type
if (activation && activationTypes.includes(activationType)) return true
if ((activation && activationTypes.includes(activationType)) || item.type === 'tool') return true
return false
}

Expand Down
2 changes: 2 additions & 0 deletions scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const ACTION_TYPE = {
check: 'tokenActionHud.dnd5e.check',
condition: 'tokenActionHud.dnd5e.condition',
effect: 'DND5E.Effect',
exhaustion: 'DND5E.Exhaustion',
feature: 'ITEM.TypeFeat',
item: 'tokenActionHud.dnd5e.item',
save: 'DND5E.ActionSave',
Expand Down Expand Up @@ -134,6 +135,7 @@ export const GROUP = {
elementalDisciplines: { id: 'elemental-disciplines', name: 'tokenActionHud.dnd5e.elementalDisciplines', type: 'system' },
equipment: { id: 'equipment', name: 'ITEM.TypeEquipmentPl', type: 'system' },
equipped: { id: 'equipped', name: 'DND5E.Equipped', type: 'system' },
exhaustion: { id: 'exhaustion', name: 'DND5E.Exhaustion', type: 'system' },
feats: { id: 'feats', name: 'tokenActionHud.dnd5e.feats', type: 'system' },
fightingStyles: { id: 'fighting-styles', name: 'tokenActionHud.dnd5e.fightingStyles', type: 'system' },
huntersPrey: { id: 'hunters-prey', name: 'tokenActionHud.dnd5e.huntersPrey', type: 'system' },
Expand Down
20 changes: 19 additions & 1 deletion scripts/roll-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
case 'effect':
await this.#toggleEffect(event, actor, actionId)
break
case 'exhaustion':
await this.#modifyExhaustion(event, actor)
break
case 'feature':
case 'item':
case 'spell':
Expand All @@ -76,6 +79,21 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
}
}

/**
* Modify Exhaustion
* @private
* @param {object} event The event
* @param {object} actor The actor
*/
async #modifyExhaustion (event, actor) {
const isRightClick = this.isRightClick(event)
const exhaustion = actor.system.attributes.exhaustion
const update = (isRightClick) ? exhaustion - 1 : exhaustion + 1
if (update >= 0) {
actor.update({ 'system.attributes.exhaustion': update })
}
}

/**
* Roll Ability
* @private
Expand Down Expand Up @@ -204,7 +222,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
break
case 'inspiration': {
const update = !actor.system.attributes.inspiration
actor.update({ 'data.attributes.inspiration': update })
actor.update({ 'system.attributes.inspiration': update })
break
}
case 'longRest':
Expand Down
2 changes: 1 addition & 1 deletion scripts/token-action-hud-dnd5e.min.js

Large diffs are not rendered by default.

0 comments on commit c353d00

Please sign in to comment.