diff --git a/scripts/powerEffects.js b/scripts/powerEffects.js index cfc3070..10525c4 100644 --- a/scripts/powerEffects.js +++ b/scripts/powerEffects.js @@ -174,6 +174,22 @@ const PowerMenus = { menuData.inputs.push({ type: 'checkbox', label: 'Greater', options: false }) menuData.inputs.push({ type: 'checkbox', label: 'Strong (lower only)', options: false }) return { menuOptions, menuData, extra: { traits } } + }, + + confusion: function (token, targets) { + if (targets.length < 1) { + shim.notifications.error('No target selected for Confusion') + return null + } + const { menuOptions, menuData } = baseMenu('Confusion', targets) + menuData.inputs.push({ type: 'checkbox', label: 'Greater (adds Shaken)', options: false }) + menuData.buttons = [ + { label: 'Distracted', value: 'distracted' }, + { label: 'Vulnerable', value: 'vulnerable' }, + { label: 'Raise (both)', value: 'raise' }, + { label: 'Cancel', value: 'cancel' } + ] + return { menuOptions, menuData, extra: {} } } } @@ -248,6 +264,23 @@ const PowerHandlers = { for (const target of targets) { shim.applyActiveEffects(target, effectDocs) } + }, + + confusion: async function (token, targets, buttons, inputs, extra) { + const { effectDocs, inputIndex } = globalModifierEffects(inputs, 'Confusion', 1) + const greater = !!inputs[inputIndex] + if (buttons === 'distracted' || buttons === 'raise') { + effectDocs.push(shim.getStatus('SWADE.Distr', 'Distracted')) + } + if (buttons === 'vulnerable' || buttons === 'raise') { + effectDocs.push(shim.getStatus('SWADE.Vuln', 'Vulnerable')) + } + if (greater) { + effectDocs.push(shim.getStatus('SWADE.Shaken', 'Shaken')) + } + for (const target of targets) { + shim.applyActiveEffects(target, effectDocs) + } } } diff --git a/scripts/shim.js b/scripts/shim.js index aca15d1..d15d6f5 100644 --- a/scripts/shim.js +++ b/scripts/shim.js @@ -24,6 +24,15 @@ export class shim { return game.user } + static getStatus (label, name) { + const effect = JSON.parse(JSON.stringify( + CONFIG.statusEffects.find(se => se.label === label))) + effect.name = ('name' in effect ? effect.name : effect.label) + effect.flags.swade.favorite = true + effect.flags.core = { statusId: effect.id } + return effect + } + static createEffectDocument (icon, name, durationRounds, changes = null) { if (changes === null) { changes = []