add confusion to supported powers

This commit is contained in:
Mike Bloy 2023-09-04 22:49:06 -05:00
parent ec5e9f770b
commit e4cf396b43
2 changed files with 42 additions and 0 deletions

View File

@ -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)
}
}
}

View File

@ -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 = []