diff --git a/src/module/powers/powers.js b/src/module/powers/powers.js index e148810..38aecb9 100644 --- a/src/module/powers/powers.js +++ b/src/module/powers/powers.js @@ -42,6 +42,7 @@ import { MindWipeEffect } from './mindWipe.js'; import { ObjectReadingEffect } from './objectReading.js'; import { PlanarBindingEffect } from './planarBinding.js'; import { PlaneShiftEffect } from './planeShift.js'; +import { ProtectionEffect } from './protection.js'; const PowerClasses = { 'arcane-protection': ArcaneProtectionEffect, @@ -97,6 +98,7 @@ const PowerClasses = { 'object-reading': ObjectReadingEffect, 'planar-binding': PlanarBindingEffect, 'plane-shift': PlaneShiftEffect, + protection: ProtectionEffect, shrink: GrowthShrinkEffect, }; diff --git a/src/module/powers/protection.js b/src/module/powers/protection.js new file mode 100644 index 0000000..9cd14e6 --- /dev/null +++ b/src/module/powers/protection.js @@ -0,0 +1,61 @@ +import { moduleName } from '../globals.js'; +import { PowerEffect } from './basePowers.js'; + +export class ProtectionEffect extends PowerEffect { + get name() { + return 'Protection'; + } + + get duration() { + return 5; + } + + get icon() { + return 'systems/swade/assets/icons/status/status_protection.svg'; + } + + get hasAdditionalRecipients() { + return true; + } + + get additionalRecipientCost() { + return 1; + } + + get basePowerPoints() { + return 1; + } + + get isTargeted() { + return true; + } + + async parseValues() { + await super.parseValues(); + const doc = await PowerEffect.getStatus('SWADE.Protection', 'Protection', false); + doc.flags = mergeObject(doc.flags ?? {}, { [moduleName]: { powerEffect: true } }); + (doc.duration = { rounds: 99 }), (this.baseEffectDoc = doc); + this.data.effect = doc; + } + + get basePrimaryEffect() { + this.data.effect.changes = this.getPrimaryEffectChanges(); + return this.data.effect; + } + + getPrimaryEffectChanges() { + const mode = CONST.ACTIVE_EFFECT_MODES.ADD; + const key = `system.stats.toughness.${this.data.raise ? 'value' : 'armor'}`; + return [...super.getPrimaryEffectChanges(), { key, mode, value: 2, priority: 0 }]; + } + + get description() { + let text = + super.description + + ` +
Grant the recipients 2 points of ${this.data.raise ? 'toughness' : 'armor'} +
+ `; + return text; + } +}