diff --git a/scripts/powerEffects.js b/scripts/powerEffects.js index 97fea85..6d1a64e 100644 --- a/scripts/powerEffects.js +++ b/scripts/powerEffects.js @@ -279,7 +279,7 @@ class ConfusionEffect extends TargetedPowerEffect { return 1 } - prepMenu () { + async prepMenu () { this.menuData.inputs.push( { type: 'checkbox', label: 'Greater (adds Shaken)', options: false }) this.menuData.buttons = [ @@ -290,7 +290,7 @@ class ConfusionEffect extends TargetedPowerEffect { ] } - prepResult () { + async prepResult () { const greater = !!this.inputs[this.inputIndex] if (this.buttons === 'distracted' || this.buttons === 'raise') { this.effectDocs.push(shim.getStatus('SWADE.Distr', 'Distracted')) @@ -313,7 +313,7 @@ class DeflectionEffect extends TargetedPowerEffect { return 5 } - prepMenu () { + async prepMenu () { this.menuData.buttons = [ { label: 'Melee', value: 'melee' }, { label: 'Ranged', value: 'ranged' }, @@ -322,7 +322,7 @@ class DeflectionEffect extends TargetedPowerEffect { ] } - prepResult () { + async prepResult () { const effectName = `Deflection (${this.buttons === 'raise' ? 'all' : this.buttons})` const icon = 'icons/magic/defensive/shield-barrier-deflect-teal.webp' this.effectDocs.push(shim.createEffectDocument(icon, effectName, this.durationRounds)) @@ -338,7 +338,7 @@ class EntangleEffect extends TargetedPowerEffect { return 1 } - prepMenu () { + async prepMenu () { this.menuData.inputs = this.menuData.inputs.concat([ { type: 'radio', label: 'Not Damaging', options: ['dmg', true] }, { type: 'radio', label: 'Damaging', options: ['dmg', false] }, @@ -352,7 +352,7 @@ class EntangleEffect extends TargetedPowerEffect { ] } - prepResult () { + async prepResult () { const damage = (this.inputs[this.inputIndex + 1] ? '2d4' : (this.inputs[this.inputIndex + 2] ? '2d6' : null)) @@ -391,7 +391,7 @@ class IntangibilityEffect extends TargetedPowerEffect { return 5 // no duration } - prepMenu () { + async prepMenu () { this.menuData.inputs.push({ type: 'checkbox', label: 'Duration', options: false }) this.menuData.buttons = [ { label: 'Apply', value: 'apply' }, @@ -399,13 +399,125 @@ class IntangibilityEffect extends TargetedPowerEffect { ] } - prepResult () { + async prepResult () { const icon = 'icons/magic/control/debuff-energy-hold-levitate-blue-yellow.webp' const effect = shim.createEffectDocument(icon, this.name, this.durationRounds, []) this.effectDocs.push(effect) } } +class InvisibilityEffect extends TargetedPowerEffect { + get name () { + return 'Invisiblity' + } + + get durationRounds () { + if (!this.inputs) { + return 5 + } + if (this.inputs[this.inputs.length - 1]) { // Duration + return 50 + } + return 5 // no duration + } + + async prepMenu () { + this.menuData.inputs.push({ type: 'checkbox', label: 'Duration', options: false }) + } + + async prepResult () { + const effect = shim.getStatus('EFFECT.StatusInvisible', 'Invisible') + effect.duration = { rounds: this.durationRounds } + this.effectDocs.push(effect) + } +} + +class ProtectionEffect extends TargetedPowerEffect { + get name () { + return 'Protection' + } + + get durationRounds () { + return 5 + } + + async prepMenu () { + this.menuData.buttons = [ + { label: 'Apply (+2 armor)', value: 'apply' }, + { label: 'Apply with raise (+2 toughness)', value: 'raise' }, + { label: 'Cancel', value: 'cancel' } + ] + } + + async prepResult () { + const effect = shim.getStatus('SWADE.Protection', 'Protection') + effect.duration = { rounds: this.durationRounds } + const mode = CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD + effect.changes = [ + { key: 'system.stats.toughness.armor', mode, value: 2, priority: 0 } + ] + if (this.buttons === 'raise') { + effect.changes[0].key = 'system.stats.toughness.value' + } + this.effectDocs.push(effect) + } +} + +class SmiteEffect extends TargetedPowerEffect { + get name () { + return 'Smite' + } + + get durationRounds () { + return 5 + } + + async prepMenu () { + this.menuData.inputs.push({ + type: 'checkbox', label: 'Greater', options: false + }) + const tokenWeapons = {} + let index = this.menuData.inputs.length - 1 + for (const token of this.targets) { + index += 2 + tokenWeapons[token.id] = index + this.menuData.inputs.push({ type: 'info', label: `