45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
|
|
|
async function main (tokens) {
|
|
const tokenList = tokens.map(t => t.name).join(', ')
|
|
const dialogOptions = {
|
|
title: 'Hurry/Hinder',
|
|
content: `Apply <em>Hurry or Hinder</em> to ${tokenList}`,
|
|
default: 'cancel',
|
|
buttons: [
|
|
{ label: 'Hurry', value: 'hurry' },
|
|
{ label: 'Hinder', value: 'hinder' },
|
|
{ label: 'Cancel', value: 'cancel' }
|
|
]
|
|
}
|
|
|
|
const choice = await warpgate.buttonDialog(dialogOptions, 'column')
|
|
|
|
if (choice && choice !== 'cancel') {
|
|
await createEffect(tokens, choice)
|
|
}
|
|
}
|
|
|
|
async function createEffect (tokens, choice) {
|
|
let icon = 'icons/skills/movement/feet-winged-boots-blue.webp'
|
|
let effectName = 'Hurry'
|
|
const changes = [
|
|
{
|
|
key: 'system.stats.speed.value',
|
|
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
|
value: 2,
|
|
priority: 0
|
|
}
|
|
]
|
|
if (choice === 'hinder') {
|
|
changes.value = '-2'
|
|
effectName = 'Hinder'
|
|
icon = 'icons/magic/movement/abstract-ribbons-red-orange.webp'
|
|
}
|
|
for (const token of tokens) {
|
|
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
|
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
|
}
|
|
}
|