update macros to use helper functions
This commit is contained in:
parent
821d2f36f9
commit
b1d7a70185
@ -88,18 +88,8 @@ async function createEffect (tokens, options) {
|
|||||||
if (mods.length > 0) {
|
if (mods.length > 0) {
|
||||||
namePart = `${namePart} (${mods.join(', ')})`
|
namePart = `${namePart} (${mods.join(', ')})`
|
||||||
}
|
}
|
||||||
const minorEffect = {
|
const minorEffect = swadeMBHelpers.createEffectDocument(
|
||||||
icon,
|
icon, `minor ${namePart}`, 5, [
|
||||||
id: `minor ${namePart}`,
|
|
||||||
label: `minor ${namePart}`,
|
|
||||||
duration: { rounds: 5 },
|
|
||||||
flags: {
|
|
||||||
swade: {
|
|
||||||
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
|
||||||
loseTurnOnHold: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
changes: [
|
|
||||||
{
|
{
|
||||||
key: options.trait.diekey,
|
key: options.trait.diekey,
|
||||||
mode,
|
mode,
|
||||||
@ -107,19 +97,9 @@ async function createEffect (tokens, options) {
|
|||||||
priority: 0
|
priority: 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
)
|
||||||
const majorEffect = {
|
const majorEffect = swadeMBHelpers.createEffectDocument(
|
||||||
icon,
|
icon, `major ${namePart}`, 5, [
|
||||||
id: `major ${namePart}`,
|
|
||||||
label: `major ${namePart}`,
|
|
||||||
duration: { rounds: 5 },
|
|
||||||
flags: {
|
|
||||||
swade: {
|
|
||||||
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
|
||||||
loseTurnOnHold: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
changes: [
|
|
||||||
{
|
{
|
||||||
key: options.trait.diekey,
|
key: options.trait.diekey,
|
||||||
mode,
|
mode,
|
||||||
@ -127,7 +107,7 @@ async function createEffect (tokens, options) {
|
|||||||
priority: 0
|
priority: 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
)
|
||||||
if (options.direction === 'Lower' && options.greater === 'Greater') {
|
if (options.direction === 'Lower' && options.greater === 'Greater') {
|
||||||
minorEffect.changes.push({
|
minorEffect.changes.push({
|
||||||
key: options.trait.modkey,
|
key: options.trait.modkey,
|
||||||
@ -146,12 +126,7 @@ async function createEffect (tokens, options) {
|
|||||||
if (raise) {
|
if (raise) {
|
||||||
mutate.embedded.ActiveEffect[majorEffect.id] = majorEffect
|
mutate.embedded.ActiveEffect[majorEffect.id] = majorEffect
|
||||||
}
|
}
|
||||||
const mutateOptions = {
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions(namePart)
|
||||||
comparisonKeys: { ActiveEffect: 'label' },
|
|
||||||
name: namePart,
|
|
||||||
permanent: true,
|
|
||||||
description: namePart
|
|
||||||
}
|
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,26 +30,8 @@ async function createEffect (tokens, choice) {
|
|||||||
effectName = `${effectName} (${choice})`
|
effectName = `${effectName} (${choice})`
|
||||||
}
|
}
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const effectData = {
|
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
|
||||||
icon,
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||||
id: effectName,
|
|
||||||
label: effectName,
|
|
||||||
duration: { rounds: 5 },
|
|
||||||
flags: {
|
|
||||||
swade: {
|
|
||||||
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
|
||||||
loseTurnOnHold: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const mutate = { embedded: { ActiveEffect: { } } }
|
|
||||||
mutate.embedded.ActiveEffect[effectName] = effectData
|
|
||||||
const mutateOptions = {
|
|
||||||
comparisonKeys: { ActiveEffect: 'label' },
|
|
||||||
name: effectName,
|
|
||||||
permanent: true,
|
|
||||||
description: effectName
|
|
||||||
}
|
|
||||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,53 +23,29 @@ async function createEffect (tokens) {
|
|||||||
const icon = 'icons/magic/light/explosion-star-blue-large.webp'
|
const icon = 'icons/magic/light/explosion-star-blue-large.webp'
|
||||||
const effectName = 'Glow'
|
const effectName = 'Glow'
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const effectData = {
|
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
|
||||||
icon,
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||||
id: effectName,
|
mutate.token = {
|
||||||
label: effectName,
|
light: {
|
||||||
duration: { rounds: 5 },
|
alpha: 0.5,
|
||||||
flags: {
|
angle: 360,
|
||||||
swade: {
|
attenuation: 0.5,
|
||||||
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
animation: {
|
||||||
loseTurnOnHold: true
|
intensity: 5,
|
||||||
}
|
reverse: false,
|
||||||
|
speed: 5,
|
||||||
|
type: 'starlight'
|
||||||
|
},
|
||||||
|
bright: 0,
|
||||||
|
color: '#0f3fff',
|
||||||
|
coloration: 1,
|
||||||
|
contrast: 0,
|
||||||
|
dim: 0.5,
|
||||||
|
luminosity: 0.5,
|
||||||
|
saturation: 0,
|
||||||
|
shadows: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// const roiling = CONFIG.Canvas.lightAnimations.roiling
|
|
||||||
const mutate = {
|
|
||||||
token: {
|
|
||||||
light: {
|
|
||||||
alpha: 0.5,
|
|
||||||
angle: 360,
|
|
||||||
attenuation: 0.5,
|
|
||||||
animation: {
|
|
||||||
intensity: 5,
|
|
||||||
reverse: false,
|
|
||||||
speed: 5,
|
|
||||||
type: 'starlight'
|
|
||||||
},
|
|
||||||
bright: 0,
|
|
||||||
color: '#0f3fff',
|
|
||||||
coloration: 1,
|
|
||||||
contrast: 0,
|
|
||||||
dim: 0.5,
|
|
||||||
luminosity: 0.5,
|
|
||||||
saturation: 0,
|
|
||||||
shadows: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
embedded: {
|
|
||||||
ActiveEffect: {
|
|
||||||
Glow: effectData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const mutateOptions = {
|
|
||||||
comparisonKeys: { ActiveEffect: 'label' },
|
|
||||||
name: effectName,
|
|
||||||
permanent: false,
|
|
||||||
description: effectName
|
|
||||||
}
|
|
||||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,27 +36,9 @@ async function createEffect (tokens, choice) {
|
|||||||
effectName = 'major Protection'
|
effectName = 'major Protection'
|
||||||
}
|
}
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const effectData = {
|
const mutate = swadeMBHelpers.createMutationWithEffect(
|
||||||
icon: baseEffect.icon,
|
baseEffect.icon, effectName, 5, changes)
|
||||||
id: effectName,
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||||
label: effectName,
|
|
||||||
duration: baseEffect.duration,
|
|
||||||
flags: {
|
|
||||||
swade: {
|
|
||||||
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
|
||||||
loseTurnOnHold: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
changes
|
|
||||||
}
|
|
||||||
const mutate = { embedded: { ActiveEffect: { } } }
|
|
||||||
mutate.embedded.ActiveEffect[effectName] = effectData
|
|
||||||
const mutateOptions = {
|
|
||||||
comparisonKeys: { ActiveEffect: 'label' },
|
|
||||||
name: effectName,
|
|
||||||
permanent: true,
|
|
||||||
description: baseEffect.label
|
|
||||||
}
|
|
||||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,53 +23,29 @@ async function createEffect (tokens) {
|
|||||||
const icon = 'icons/magic/perception/silhouette-stealth-shadow.webp'
|
const icon = 'icons/magic/perception/silhouette-stealth-shadow.webp'
|
||||||
const effectName = 'Shroud'
|
const effectName = 'Shroud'
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const effectData = {
|
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
|
||||||
icon,
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||||
id: effectName,
|
mutate.token = {
|
||||||
label: effectName,
|
light: {
|
||||||
duration: { rounds: 5 },
|
alpha: 0.5,
|
||||||
flags: {
|
angle: 360,
|
||||||
swade: {
|
attenuation: 0.1,
|
||||||
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
animation: {
|
||||||
loseTurnOnHold: true
|
intensity: 5,
|
||||||
}
|
reverse: false,
|
||||||
|
speed: 5,
|
||||||
|
type: 'roiling'
|
||||||
|
},
|
||||||
|
bright: 0,
|
||||||
|
color: null,
|
||||||
|
coloration: 0,
|
||||||
|
contrast: 0,
|
||||||
|
dim: 0.1,
|
||||||
|
luminosity: -0.15,
|
||||||
|
saturation: 0,
|
||||||
|
shadows: 0.25
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// const roiling = CONFIG.Canvas.lightAnimations.roiling
|
|
||||||
const mutate = {
|
|
||||||
token: {
|
|
||||||
light: {
|
|
||||||
alpha: 0.5,
|
|
||||||
angle: 360,
|
|
||||||
attenuation: 0.1,
|
|
||||||
animation: {
|
|
||||||
intensity: 5,
|
|
||||||
reverse: false,
|
|
||||||
speed: 5,
|
|
||||||
type: 'roiling'
|
|
||||||
},
|
|
||||||
bright: 0,
|
|
||||||
color: null,
|
|
||||||
coloration: 0,
|
|
||||||
contrast: 0,
|
|
||||||
dim: 0.1,
|
|
||||||
luminosity: -0.15,
|
|
||||||
saturation: 0,
|
|
||||||
shadows: 0.25
|
|
||||||
}
|
|
||||||
},
|
|
||||||
embedded: {
|
|
||||||
ActiveEffect: {
|
|
||||||
Shroud: effectData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const mutateOptions = {
|
|
||||||
comparisonKeys: { ActiveEffect: 'label' },
|
|
||||||
name: effectName,
|
|
||||||
permanent: false,
|
|
||||||
description: effectName
|
|
||||||
}
|
|
||||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,8 @@ async function main (tokens) {
|
|||||||
const menuData = {
|
const menuData = {
|
||||||
inputs: [
|
inputs: [
|
||||||
{ type: 'header', label: 'Smite' },
|
{ type: 'header', label: 'Smite' },
|
||||||
{ type: 'info', label: `Apply Smite to ${tokenList}` }
|
{ type: 'info', label: `Apply Smite to ${tokenList}` },
|
||||||
|
{ type: 'checkbox', label: 'Greater', options: false }
|
||||||
],
|
],
|
||||||
buttons: [
|
buttons: [
|
||||||
{ label: 'Apply', value: 'apply' },
|
{ label: 'Apply', value: 'apply' },
|
||||||
@ -21,7 +22,7 @@ async function main (tokens) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tokenWeapons = {}
|
const tokenWeapons = {}
|
||||||
let index = 1
|
let index = 2
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
index += 2
|
index += 2
|
||||||
tokenWeapons[token.id] = index
|
tokenWeapons[token.id] = index
|
||||||
@ -35,17 +36,20 @@ async function main (tokens) {
|
|||||||
for (const tokenId in tokenWeapons) {
|
for (const tokenId in tokenWeapons) {
|
||||||
tokenWeapons[tokenId] = inputs[tokenWeapons[tokenId]]
|
tokenWeapons[tokenId] = inputs[tokenWeapons[tokenId]]
|
||||||
}
|
}
|
||||||
|
const greater = (inputs[2] === 'Greater')
|
||||||
if (buttons && buttons !== 'cancel') {
|
if (buttons && buttons !== 'cancel') {
|
||||||
await createEffect(tokens, tokenWeapons, buttons)
|
await createEffect(tokens, tokenWeapons, buttons, greater)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createEffect (tokens, tokenWeapons, choice) {
|
async function createEffect (tokens, tokenWeapons, choice, greater) {
|
||||||
const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Smite')
|
const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Smite')
|
||||||
const effectIcon = baseEffect.icon
|
const effectIcon = baseEffect.icon
|
||||||
const effectId = baseEffect.id
|
const effectId = baseEffect.id
|
||||||
const changeValue = (choice === 'raise' ? '+4' : '+2')
|
let changeValue = (choice === 'raise' ? '+4' : '+2')
|
||||||
|
if (greater) {
|
||||||
|
changeValue = (choice === 'raise' ? '+6' : '+4')
|
||||||
|
}
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const weaponName = tokenWeapons[token.id]
|
const weaponName = tokenWeapons[token.id]
|
||||||
const weaponId = token.actor.items.getName(weaponName)?.id
|
const weaponId = token.actor.items.getName(weaponName)?.id
|
||||||
@ -53,37 +57,18 @@ async function createEffect (tokens, tokenWeapons, choice) {
|
|||||||
if (!weaponId) {
|
if (!weaponId) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const effectName = `${choice === 'raise' ? 'major' : 'minor'} Smite (${weaponName})`
|
const effectName = `${choice === 'raise' ? 'major' : 'minor'} Smite${greater ? '(greater)' : ''} (${weaponName})`
|
||||||
const effectData = {
|
const changes = [
|
||||||
icon: effectIcon,
|
{
|
||||||
id: effectId,
|
key: changeKey,
|
||||||
label: effectName,
|
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
||||||
duration: { rounds: 5 },
|
value: changeValue,
|
||||||
flags: {
|
priority: 0
|
||||||
swade: {
|
}
|
||||||
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
]
|
||||||
loseTurnOnHold: true
|
const mutate = swadeMBHelpers.createMutationWithEffect(
|
||||||
}
|
effectIcon, effectName, 5, changes)
|
||||||
},
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||||
changes: [
|
|
||||||
{
|
|
||||||
key: changeKey,
|
|
||||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
|
||||||
value: changeValue,
|
|
||||||
priority: 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
const mutate = {
|
|
||||||
embedded: { ActiveEffect: {} }
|
|
||||||
}
|
|
||||||
mutate.embedded.ActiveEffect[effectName] = effectData
|
|
||||||
const mutateOptions = {
|
|
||||||
comparisonKeys: { ActiveEffect: 'label' },
|
|
||||||
name: effectName,
|
|
||||||
permanent: true,
|
|
||||||
description: 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
Loading…
x
Reference in New Issue
Block a user