add several helper functions for macro creation
This commit is contained in:
parent
7319e54519
commit
821d2f36f9
@ -9,7 +9,10 @@ export class api {
|
|||||||
static globals () {
|
static globals () {
|
||||||
globalThis.swadeMBHelpers = {
|
globalThis.swadeMBHelpers = {
|
||||||
DEBUG: true,
|
DEBUG: true,
|
||||||
runOnTargetOrSelectedTokens: helpers.runOnTargetOrSelectedTokens
|
runOnTargetOrSelectedTokens: helpers.runOnTargetOrSelectedTokens,
|
||||||
|
createEffectDocument: helpers.createEffectDocument,
|
||||||
|
createMutationWithEffect: helpers.createMutationWithEffect,
|
||||||
|
defaultMutationOptions: helpers.defaultMutationOptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,4 +13,40 @@ export class helpers {
|
|||||||
ui.notifications.error('Please select or target a token')
|
ui.notifications.error('Please select or target a token')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static createEffectDocument (icon, name, durationRounds, changes) {
|
||||||
|
const effectData = {
|
||||||
|
icon,
|
||||||
|
id: name,
|
||||||
|
label: name,
|
||||||
|
duration: { rounds: 5 },
|
||||||
|
flags: {
|
||||||
|
swade: {
|
||||||
|
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
||||||
|
loseTurnOnHold: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
changes
|
||||||
|
}
|
||||||
|
return effectData
|
||||||
|
}
|
||||||
|
|
||||||
|
static createMutationWithEffect (icon, name, durationRounds, changes) {
|
||||||
|
const effect = helpers.createEffectDocument(icon, name, durationRounds, changes)
|
||||||
|
const mutate = {
|
||||||
|
embedded: { ActiveEffect: {} }
|
||||||
|
}
|
||||||
|
mutate.embedded.ActiveEffect[name] = effect
|
||||||
|
return mutate
|
||||||
|
}
|
||||||
|
|
||||||
|
static defaultMutationOptions (name) {
|
||||||
|
const mutateOptions = {
|
||||||
|
comparisonKeys: { ActiveEffect: 'label' },
|
||||||
|
name,
|
||||||
|
permanent: false,
|
||||||
|
description: name
|
||||||
|
}
|
||||||
|
return mutateOptions
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user