@@ -1,6 +1,3 @@
|
||||
|
||||
import { SYSTEM } from "../../config/system.mjs"
|
||||
|
||||
export let RollHandler = null
|
||||
|
||||
Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||
@@ -66,7 +63,6 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||
* @param {string} actionId The actionId
|
||||
*/
|
||||
async #handleAction(event, actor, token, actionTypeId, actionId) {
|
||||
console.log('Handling action', actionId, 'of type', actionTypeId, 'for actor', actor.name)
|
||||
switch (actionTypeId) {
|
||||
case 'characteristics':
|
||||
await this.#handleCharacteristicsAction(event, actor, actionId)
|
||||
@@ -100,19 +96,17 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||
* @param {string} actionId The action id
|
||||
*/
|
||||
async #handleCharacteristicsAction(event, actor, actionId) {
|
||||
let rollType
|
||||
if (actionId === 'wp' || actionId === 'hp') return
|
||||
|
||||
if (actionId.includes('_add') || actionId.includes('_subtract')) {
|
||||
const attr = actionId.split('_')[0]
|
||||
const action = actionId.split('_')[1]
|
||||
console.log('Updating', attr, 'with action', action)
|
||||
const update = {}
|
||||
update.system = {}
|
||||
update.system[attr] = {}
|
||||
update.system[attr].value = action === 'add' ? this.actor.system[attr].value + 1 : this.actor.system[attr].value - 1
|
||||
if (update.system[attr].value > this.actor.system[attr].max || update.system[attr].value < this.actor.system[attr].min) return
|
||||
return await this.actor.update(update)
|
||||
update.system[attr].value = action === 'add' ? actor.system[attr].value + 1 : actor.system[attr].value - 1
|
||||
if (update.system[attr].value > actor.system[attr].max || update.system[attr].value < actor.system[attr].min) return
|
||||
return await actor.update(update)
|
||||
}
|
||||
if (actionId === 'san') {
|
||||
let item = foundry.utils.duplicate(actor.system.san)
|
||||
@@ -155,7 +149,8 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||
* @param {string} actionId The action id
|
||||
*/
|
||||
async #handleWeaponsAction(event, actor, actionId) {
|
||||
let weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
|
||||
const weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
|
||||
if (!weapon) return ui.notifications.warn(`Weapon not found for action id '${actionId}'`)
|
||||
weapon.damageFormula = weapon.system.damage
|
||||
weapon.damageBonus = actor.system.damageBonus
|
||||
await actor.system.roll('weapon', weapon)
|
||||
@@ -169,7 +164,8 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||
* @param {string} actionId The action id
|
||||
*/
|
||||
async #handleDamageAction(event, actor, actionId) {
|
||||
let weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
|
||||
const weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
|
||||
if (!weapon) return ui.notifications.warn(`Weapon not found for action id '${actionId}'`)
|
||||
weapon.damageFormula = weapon.system.damage
|
||||
weapon.damageBonus = actor.system.damageBonus
|
||||
await actor.system.roll('damage', weapon)
|
||||
@@ -183,13 +179,13 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||
* @param {string} actionId The action id
|
||||
*/
|
||||
async #handleLethalityAction(event, actor, actionId) {
|
||||
const item = await this.actor.items.get(actionId)
|
||||
const item = actor.items.get(actionId)
|
||||
if (item.system.damage !== '' && event.ctrlKey) {
|
||||
const isLethal = !item.system.isLethal
|
||||
await item.update({ 'system.isLethal': isLethal })
|
||||
} else {
|
||||
const options = {
|
||||
actor: this.actor,
|
||||
actor,
|
||||
rollType: 'lethality',
|
||||
key: item.system.lethality,
|
||||
item
|
||||
|
||||
Reference in New Issue
Block a user