42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
|
|
|
async function main (tokens) {
|
|
const tokenList = tokens.map(t => t.name).join(', ')
|
|
const menuOptions = {
|
|
title: 'Intangibility',
|
|
defaultButton: 'Cancel',
|
|
options: {}
|
|
}
|
|
|
|
const menuData = {
|
|
inputs: [
|
|
{ type: 'header', label: 'Intangibility' },
|
|
{ type: 'info', label: `Apply Intangibility to ${tokenList}` },
|
|
{ type: 'checkbox', label: 'Duration', options: false }
|
|
],
|
|
buttons: [
|
|
{ label: 'Apply', value: 'apply' },
|
|
{ label: 'Cancel', value: 'cancel' }
|
|
]
|
|
}
|
|
|
|
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
|
if (buttons && buttons !== 'cancel') {
|
|
const options = {
|
|
duration: (!!inputs[2])
|
|
}
|
|
await createEffect(tokens, options)
|
|
}
|
|
}
|
|
|
|
async function createEffect (tokens, options) {
|
|
const effectName = 'Intangibility'
|
|
const duration = (options.duration ? 5 * 6 * 60 : 5)
|
|
const icon = 'icons/magic/control/debuff-energy-hold-levitate-blue-yellow.webp'
|
|
for (const token of tokens) {
|
|
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, duration, [])
|
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions('Intangibility')
|
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
|
}
|
|
}
|