add hurry-hinder macro

This commit is contained in:
Mike Bloy 2023-03-02 18:11:05 -06:00
parent f170896d1a
commit f689b0fc48
2 changed files with 52 additions and 7 deletions

44
macros/hurry-hinder.js Normal file
View File

@ -0,0 +1,44 @@
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)
}
}

File diff suppressed because one or more lines are too long