boost/lower added to new effect macro
This commit is contained in:
parent
4adde0852b
commit
ec5e9f770b
@ -116,20 +116,69 @@ function globalModifierEffects (inputs, basename, durationRounds) {
|
|||||||
return { effectDocs, inputIndex }
|
return { effectDocs, inputIndex }
|
||||||
}
|
}
|
||||||
|
|
||||||
class PowerMenus {
|
const PowerMenus = {
|
||||||
static blind (token, targets) {
|
blind: function (token, targets) {
|
||||||
|
if (targets.length < 1) {
|
||||||
|
shim.notifications.error('No target selected for Blind')
|
||||||
|
return null
|
||||||
|
}
|
||||||
const { menuOptions, menuData } = baseMenu('Blind', targets)
|
const { menuOptions, menuData } = baseMenu('Blind', targets)
|
||||||
menuData.inputs.push({
|
menuData.inputs.push({
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
label: 'Strong (+1 point)',
|
label: 'Strong (+1 point)',
|
||||||
options: false
|
options: false
|
||||||
})
|
})
|
||||||
return { menuOptions, menuData }
|
return { menuOptions, menuData, extra: {} }
|
||||||
|
},
|
||||||
|
|
||||||
|
'boost/lower trait': function (token, targets) {
|
||||||
|
if (targets.length < 1) {
|
||||||
|
shim.notifications.error('No target selected for Boost/Lower Trait')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const { menuOptions, menuData } = baseMenu('Boost/Lower Trait', targets)
|
||||||
|
let traitOptions = ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor']
|
||||||
|
const allSkills = []
|
||||||
|
const traits = {}
|
||||||
|
for (const traitName of traitOptions) {
|
||||||
|
const lower = traitName.toLowerCase()
|
||||||
|
traits[traitName] = {
|
||||||
|
name: traitName,
|
||||||
|
type: 'attribute',
|
||||||
|
modkey: `system.attributes.${lower}.die.modifier`,
|
||||||
|
diekey: `system.attributes.${lower}.die.sides`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const token of targets) {
|
||||||
|
const skills = token.actor.items.filter(item => item.type === 'skill')
|
||||||
|
for (const skill of skills) {
|
||||||
|
const name = skill.name
|
||||||
|
traits[name] = {
|
||||||
|
name,
|
||||||
|
type: 'skill',
|
||||||
|
modkey: `@Skill{${name}}[system.die.modifier]`,
|
||||||
|
diekey: `@Skill{${name}}[system.die.sides]`
|
||||||
|
}
|
||||||
|
if (name !== 'Unskilled' && !allSkills.find(v => v === name)) {
|
||||||
|
allSkills.push(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
traitOptions = traitOptions.concat(allSkills.sort())
|
||||||
|
}
|
||||||
|
menuData.inputs.push({
|
||||||
|
type: 'select', label: 'Trait', options: traitOptions
|
||||||
|
})
|
||||||
|
menuData.inputs.push({ type: 'info', label: 'Boost or Lower?' })
|
||||||
|
menuData.inputs.push({ type: 'radio', label: 'Boost', options: ['isBoost', true] })
|
||||||
|
menuData.inputs.push({ type: 'radio', label: 'Lower', options: ['isBoost', false] })
|
||||||
|
menuData.inputs.push({ type: 'checkbox', label: 'Greater', options: false })
|
||||||
|
menuData.inputs.push({ type: 'checkbox', label: 'Strong (lower only)', options: false })
|
||||||
|
return { menuOptions, menuData, extra: { traits } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PowerHandlers {
|
const PowerHandlers = {
|
||||||
static async blind (token, targets, buttons, inputs) {
|
blind: async function (token, targets, buttons, inputs, extra) {
|
||||||
const raise = (buttons === 'raise')
|
const raise = (buttons === 'raise')
|
||||||
const { effectDocs, inputIndex } = globalModifierEffects(inputs, 'Blind', 1)
|
const { effectDocs, inputIndex } = globalModifierEffects(inputs, 'Blind', 1)
|
||||||
const strong = !!inputs[inputIndex]
|
const strong = !!inputs[inputIndex]
|
||||||
@ -138,25 +187,67 @@ class PowerHandlers {
|
|||||||
{
|
{
|
||||||
key: 'system.stats.globalMods.trait',
|
key: 'system.stats.globalMods.trait',
|
||||||
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD,
|
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD,
|
||||||
value: -2,
|
value: '-2',
|
||||||
priority: 0
|
priority: 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
effectDocs.push(
|
effectDocs.push(
|
||||||
shim.createEffectDocument(
|
shim.createEffectDocument(
|
||||||
icon, `minor Blindness (Vigor ${strong ? '-2 ' : ''}ends)`, 1)
|
icon, `minor Blindness (Vigor ${strong ? '-2 ' : ''}ends)`, 1, changes)
|
||||||
)
|
)
|
||||||
effectDocs[effectDocs.length - 1].changes = changes
|
|
||||||
if (raise) {
|
if (raise) {
|
||||||
effectDocs.push(
|
effectDocs.push(
|
||||||
shim.createEffectDocument(
|
shim.createEffectDocument(
|
||||||
icon, `major Blindness (Vigor ${strong ? '-2 ' : ''}ends)`, 1)
|
icon, `major Blindness (Vigor ${strong ? '-2 ' : ''}ends)`, 1, changes)
|
||||||
)
|
)
|
||||||
effectDocs[effectDocs.length - 1].changes = changes
|
|
||||||
}
|
}
|
||||||
for (const target of targets) {
|
for (const target of targets) {
|
||||||
shim.applyActiveEffects(target, effectDocs)
|
shim.applyActiveEffects(target, effectDocs)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'boost/lower trait': async function (token, targets, buttons, inputs, extra) {
|
||||||
|
const raise = (buttons === 'raise')
|
||||||
|
const direction = inputs[inputs.length - 4] ? 'Boost' : 'Lower'
|
||||||
|
const durationRounds = (direction === 'Boost' ? 5 : 1)
|
||||||
|
const { effectDocs, inputIndex } = globalModifierEffects(
|
||||||
|
inputs, 'Boost/Lower Trait', durationRounds)
|
||||||
|
const icon = (direction === 'Boost'
|
||||||
|
? 'icons/magic/life/cross-embers-glow-yellow-purple.webp'
|
||||||
|
: 'icons/magic/movement/chevrons-down-yellow.webp')
|
||||||
|
const trait = extra.traits[inputs[inputIndex]]
|
||||||
|
const greater = !!inputs[inputIndex + 4]
|
||||||
|
const strong = !!inputs[inputIndex + 5]
|
||||||
|
|
||||||
|
let namePart = `${direction} ${trait.name}`
|
||||||
|
const mods = []
|
||||||
|
if (direction === 'Lower') {
|
||||||
|
mods.push(`Spirit${strong ? '-2' : ''} ends`)
|
||||||
|
}
|
||||||
|
if (greater) {
|
||||||
|
mods.push('greater')
|
||||||
|
}
|
||||||
|
if (mods.length > 0) {
|
||||||
|
namePart = `${namePart} (${mods.join(', ')})`
|
||||||
|
}
|
||||||
|
const mode = CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD
|
||||||
|
const modValue = (direction === 'Boost' ? '+2' : '-2')
|
||||||
|
const minorEffect = shim.createEffectDocument(
|
||||||
|
icon, `minor ${namePart}`, durationRounds, [
|
||||||
|
{ key: trait.diekey, mode, value: modValue, priority: 0 }
|
||||||
|
])
|
||||||
|
if (direction === 'Lower' && greater) {
|
||||||
|
minorEffect.changes.push({ key: trait.modkey, mode, value: modValue, priority: 0 })
|
||||||
|
}
|
||||||
|
const majorEffect = shim.createEffectDocument(
|
||||||
|
icon, `major ${namePart}`, durationRounds, [
|
||||||
|
{ key: trait.diekey, mode, value: modValue, priority: 0 }
|
||||||
|
])
|
||||||
|
effectDocs.push(minorEffect)
|
||||||
|
if (raise) { effectDocs.push(majorEffect) }
|
||||||
|
for (const target of targets) {
|
||||||
|
shim.applyActiveEffects(target, effectDocs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,10 +263,12 @@ export async function powerEffects (options = {}) {
|
|||||||
|
|
||||||
const lcName = name.toLowerCase()
|
const lcName = name.toLowerCase()
|
||||||
if (lcName in PowerMenus && lcName in PowerHandlers) {
|
if (lcName in PowerMenus && lcName in PowerHandlers) {
|
||||||
const { menuOptions, menuData } = PowerMenus[lcName](token, targets)
|
const data = PowerMenus[lcName](token, targets)
|
||||||
|
if (data === null) { return }
|
||||||
|
const { menuOptions, menuData, extra } = data
|
||||||
const { buttons, inputs } = await shim.warpgateMenu(menuData, menuOptions)
|
const { buttons, inputs } = await shim.warpgateMenu(menuData, menuOptions)
|
||||||
if (buttons && buttons !== 'cancel') {
|
if (buttons && buttons !== 'cancel') {
|
||||||
await PowerHandlers[lcName](token, targets, buttons, inputs)
|
await PowerHandlers[lcName](token, targets, buttons, inputs, extra)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,13 +24,18 @@ export class shim {
|
|||||||
return game.user
|
return game.user
|
||||||
}
|
}
|
||||||
|
|
||||||
static createEffectDocument (icon, name, durationRounds) {
|
static createEffectDocument (icon, name, durationRounds, changes = null) {
|
||||||
|
if (changes === null) {
|
||||||
|
changes = []
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
icon,
|
icon,
|
||||||
name,
|
name,
|
||||||
duration: { rounds: durationRounds },
|
duration: { rounds: durationRounds },
|
||||||
|
changes,
|
||||||
flags: {
|
flags: {
|
||||||
swade: {
|
swade: {
|
||||||
|
favorite: true,
|
||||||
expiration: CONST.SWADE.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt
|
expiration: CONST.SWADE.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user