46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
|
|
|
async function main (tokens) {
|
|
const tokenList = tokens.map(t => t.name).join(', ')
|
|
const menuOptions = {
|
|
title: 'Blind',
|
|
defaultButton: 'Cancel',
|
|
options: {}
|
|
}
|
|
|
|
const menuData = {
|
|
inputs: [
|
|
{ type: 'header', label: 'Blind' },
|
|
{ type: 'info', label: `Apply Blind to ${tokenList}` },
|
|
{ type: 'checkbox', label: 'Strong', options: false }
|
|
],
|
|
buttons: [
|
|
{ label: 'Apply', value: 'apply' },
|
|
{ label: 'Raise', value: 'raise' },
|
|
{ label: 'Cancel', value: 'cancel' }
|
|
]
|
|
}
|
|
|
|
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
|
if (buttons && buttons !== 'cancel') {
|
|
const options = {
|
|
raise: (buttons === 'raise'),
|
|
strong: (!!inputs[2])
|
|
}
|
|
await createEffect(tokens, options)
|
|
}
|
|
}
|
|
|
|
async function createEffect (tokens, options) {
|
|
const effectDetails = (options.raise ? '-4' : '-2')
|
|
const effectEnd = (options.strong ? 'Vigor -2' : 'Vigor')
|
|
const effectName = `Blind (${effectDetails}) ${effectEnd} ends`
|
|
const baseEffect = CONFIG.statusEffects.find(se => se.label === 'EFFECT.StatusBlind')
|
|
for (const token of tokens) {
|
|
const mutate = swadeMBHelpers.createMutationWithEffect(baseEffect.icon, effectName, 1, [])
|
|
mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }
|
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions('Blind')
|
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
|
}
|
|
}
|