fix hurry/hinder, split into two

closes #5
This commit is contained in:
Mike Bloy 2023-03-04 14:04:21 -06:00
parent 262a43af84
commit 58e2b033ae
3 changed files with 54 additions and 21 deletions

38
macros/hinder.js Normal file
View File

@ -0,0 +1,38 @@
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
async function main (tokens) {
const tokenList = tokens.map(t => t.name).join(', ')
const dialogOptions = {
title: 'Hinder',
content: `Apply <em>Hinder</em> to ${tokenList}`,
default: 'cancel',
buttons: [
{ label: 'OK', value: 'ok' },
{ label: 'Cancel', value: 'cancel' }
]
}
const choice = await warpgate.buttonDialog(dialogOptions, 'column')
if (choice === 'ok') {
await createEffect(tokens, choice)
}
}
async function createEffect (tokens, choice) {
const icon = 'icons/magic/movement/abstract-ribbons-red-orange.webp'
const effectName = 'Hinder'
const changes = [
{
key: 'system.stats.speed.value',
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
value: -2,
priority: 0
}
]
for (const token of tokens) {
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, changes)
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
}
}

View File

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

File diff suppressed because one or more lines are too long