From 6a7dd696ca8b6f00b31c97ef9a6bd67066424607 Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sun, 19 May 2024 18:44:20 -0500 Subject: [PATCH] add entangle --- src/module/powers/entangle.js | 114 ++++++++++++++++++++++++++++++++++ src/module/powers/powers.js | 2 + 2 files changed, 116 insertions(+) create mode 100644 src/module/powers/entangle.js diff --git a/src/module/powers/entangle.js b/src/module/powers/entangle.js new file mode 100644 index 0000000..0ae69c4 --- /dev/null +++ b/src/module/powers/entangle.js @@ -0,0 +1,114 @@ +import { moduleName } from '../globals.js'; +import { PowerEffect } from './basePowers.js'; + +export class EntangleEffect extends PowerEffect { + get name() { + return 'Entangle'; + } + + get duration() { + return 0; + } + + get icon() { + return 'icons/magic/nature/root-vine-entangled-humanoid.webp'; + } + + get isDamaging() { + return true; + } + + get basePowerPoints() { + return 2; + } + + get usePrimaryEffect() { + return false; + } + + get isTargeted() { + return true; + } + + get modifiers() { + return [ + ...super.modifiers, + { + type: 'select', + name: 'Damage', + id: 'damage', + epic: false, + default: 'none', + choices: { + none: 'None', + damage: 'Damage', + deadly: '⭐ Deadly', + }, + effects: { none: null, damage: null, deadly: null }, + values: { none: 0, damage: 2, deadly: 4 }, + }, + { + type: 'checkbox', + default: false, + name: 'Tough', + value: 1, + epic: false, + effect: false, + }, + { + type: 'select', + default: 'none', + name: 'Area of Effect', + id: 'aoe', + epic: true, + choices: { + none: 'None', + mbt: 'Medium Blast Template', + lbt: 'Large Blast Template', + }, + effects: { none: null, mbt: null, lbt: null }, + values: { none: 0, mbt: 2, lbt: 3 }, + }, + ]; + } + + async createSecondaryEffects(maintId) { + const docs = await super.createSecondaryEffects(maintId); + const docLabel = this.data.raise ? 'SWADE.Bound' : 'SWADE.Entangled'; + const docName = this.data.raise ? 'Bound' : 'Entangled'; + const doc = await PowerEffect.getStatus(docLabel, docName, false); + doc.flags = mergeObject(doc.flags ?? {}, { + [moduleName]: { + powerEffect: true, + maintId, + }, + }); + if (this.data.damage !== 'none') { + const dmg = this.data.damage === 'deadly' ? '2d6' : '2d4'; + doc.flags[moduleName].buttons = [ + { + label: `Damage (${dmg})`, + type: 'damage', + formula: `${dmg}x`, + }, + ]; + } + docs.push(doc); + return docs; + } + + get description() { + let text = ` +

Target(s) are restrained by something trapping-appropriate of Hardness + ${this.data.tough ? 10 : 8}, and are ${this.data.raise ? 'Bound' : 'Entangled'}. + `; + if (this.data.damage !== 'none') { + text += `While restrained, victims take + ${this.data.damage === 'deadly' ? '2d6' : '2d4'} damage at the end of + their turn. + `; + } + text += '

'; + return super.description + text; + } +} diff --git a/src/module/powers/powers.js b/src/module/powers/powers.js index 7e7aa1b..c5fde19 100644 --- a/src/module/powers/powers.js +++ b/src/module/powers/powers.js @@ -23,6 +23,7 @@ import { DivinationEffect } from './divination.js'; import { DrainPowerPointsEffect } from './drainPowerPoints.js'; import { ElementalManipulationEffect } from './elementalManipulation.js'; import { EmpathyEffect } from './empathy.js'; +import { EntangleEffect } from './entangle.js'; const PowerClasses = { 'arcane-protection': ArcaneProtectionEffect, @@ -53,6 +54,7 @@ const PowerClasses = { 'drain-power-points': DrainPowerPointsEffect, 'elemental-manipulation': ElementalManipulationEffect, empathy: EmpathyEffect, + entangle: EntangleEffect, 'lower-trait': BoostLowerTraitEffect, };