add entangle new style

This commit is contained in:
Mike Bloy 2023-09-05 22:04:30 -05:00
parent da25549c09
commit d7c452879d
6 changed files with 54 additions and 27 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -205,6 +205,26 @@ const PowerMenus = {
{ label: 'Cancel', value: 'cancel' }
]
return { menuOptions, menuData, extra: {} }
},
entangle: function (token, targets) {
if (targets.length < 1) {
shim.notifications.error('No target selected for Deflection')
return null
}
const { menuOptions, menuData } = baseMenu('Entangle', targets)
menuData.inputs = menuData.inputs.concat([
{ type: 'radio', label: 'Not Damaging', options: ['dmg', true] },
{ type: 'radio', label: 'Damaging', options: ['dmg', false] },
{ type: 'radio', label: 'Deadly', options: ['dmg', false] },
{ type: 'checkbox', label: 'Tough', options: false }
])
menuData.buttons = [
{ label: 'Entangled', value: 'apply' },
{ label: 'Bound (raise)', value: 'raise' },
{ label: 'Cancel', value: 'cancel' }
]
return { menuOptions, menuData, extra: {} }
}
}
@ -306,6 +326,30 @@ const PowerHandlers = {
for (const target of targets) {
shim.applyActiveEffects(target, effectDocs)
}
},
entangle: async function (token, targets, buttons, inputs, extra) {
const { effectDocs, inputIndex } = globalModifierEffects(inputs, 'Entangle', 1)
const damage = (inputs[inputIndex + 1] ? '2d4' : (inputs[inputIndex + 2] ? '2d6' : null))
const tough = !!inputs[inputIndex + 3]
const effectSearch = (buttons === 'raise' ? 'SWADE.Bound' : 'SWADE.Entangled')
const effectName = (buttons === 'raise' ? 'Bound' : 'Entangled')
const effect = shim.getStatus(effectSearch, effectName)
const extraIcon = 'icons/magic/nature/root-vine-barrier-wall-brown.webp'
const extraEffect = shim.createEffectDocument(extraIcon, 'Entangle Modifier', 1, [])
if (damage) {
extraEffect.name = `${extraEffect.name} - ${damage} dmg`
}
if (tough) {
extraEffect.name = `Tough ${extraEffect.name}`
}
effectDocs.push(effect)
if (damage || tough) {
effectDocs.push(extraEffect)
}
for (const target of targets) {
shim.applyActiveEffects(target, effectDocs)
}
}
}

View File

@ -24,11 +24,19 @@ export class shim {
return game.user
}
static getStatus (label, name) {
static getStatus (label, name, favorite = true) {
const effect = JSON.parse(JSON.stringify(
CONFIG.statusEffects.find(se => se.label === label)))
effect.name = ('name' in effect ? effect.name : effect.label)
effect.flags.swade.favorite = true
if (!('flags' in effect)) {
effect.flags = {}
}
if (favorite) {
if (!('swade' in effect.flags)) {
effect.flags.swade = {}
}
effect.flags.swade.favorite = true
}
effect.flags.core = { statusId: effect.id }
return effect
}