From ae3bc394e722c667fcb76566fd143fe56067fc44 Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Mon, 20 May 2024 23:01:25 -0500 Subject: [PATCH] add growth shrink --- src/module/powers/basePowers.js | 8 +++ src/module/powers/growthShrink.js | 94 ++++++++++++++++++++++++++++++- src/module/powers/powers.js | 7 ++- src/templates/powerDialog.html | 13 ++++- 4 files changed, 118 insertions(+), 4 deletions(-) diff --git a/src/module/powers/basePowers.js b/src/module/powers/basePowers.js index 0ee5220..1d59308 100644 --- a/src/module/powers/basePowers.js +++ b/src/module/powers/basePowers.js @@ -43,6 +43,9 @@ export class PowerFormApplication extends FormApplication { modifier.isRadio = modifier.type === 'radio'; modifier.isNumber = modifier.type === 'number'; modifier.isText = modifier.type === 'text'; + if (modifier.isNumber) { + modifier.step = modifier?.step ?? 1; + } if (modifier.isSelect || modifier.isRadio) { for (const choice in modifier.choices) { let val = ''; @@ -63,6 +66,7 @@ export class PowerFormApplication extends FormApplication { number: 0, total: 0, }, + extraDescription: this.powerEffect.extraDescription, targets: [], buttons: this.powerEffect.menuButtons, }; @@ -154,6 +158,10 @@ export class PowerEffect { return this.name; } + get extraDescription() { + return ''; + } + get icon() { return 'icons/magic/symbols/question-stone-yellow.webp'; } diff --git a/src/module/powers/growthShrink.js b/src/module/powers/growthShrink.js index 8cff9fe..448b5e2 100644 --- a/src/module/powers/growthShrink.js +++ b/src/module/powers/growthShrink.js @@ -10,11 +10,22 @@ export class GrowthShrinkEffect extends PowerEffect { } get basePowerPoints() { - return 2; + return 0; } get duration() { - return 5; + return this?.data?.duration ? 50 : 5; + } + + get extraDescription() { + const target = this.targets?.[0]; + let text = super.extraDescription + '

Minimum Size is -2. '; + if (target) { + text += `${target.name} is of Size ${target.actor.system.stats.size}. `; + } + text += `Select the number of Size steps to change the target. 2 points per + step. Negative is shrink, positive is growth.

`; + return text; } get isTargeted() { @@ -25,9 +36,25 @@ export class GrowthShrinkEffect extends PowerEffect { return true; } + get isRaisable() { + return false; + } + get modifiers() { + const curSize = this.targets?.[0]?.actor?.system?.stats?.size ?? 0; + const minSteps = -2 - curSize; return [ ...super.modifiers, + { + name: 'Size Steps', + default: 1, + type: 'number', + min: minSteps, + value: 0, + id: 'steps', + epic: false, + effect: false, + }, { name: 'Duration', id: 'duration', @@ -48,4 +75,67 @@ export class GrowthShrinkEffect extends PowerEffect { }, ]; } + + async parseValues() { + await super.parseValues(); + const steps = this.data.steps; + const curSize = this.targets?.[0]?.actor?.system?.stats?.size ?? 0; + const minSteps = -2 - curSize; + this.data.steps = Math.max(steps, minSteps); + } + + get powerPoints() { + return super.powerPoints + Math.abs(this.data.steps) * 2; + } + + getPrimaryEffectChanges() { + const steps = this.data.steps; + const changes = super.getPrimaryEffectChanges(); + if (steps === 0) { + return changes; + } + changes.push({ + key: 'system.stats.size', + value: steps, + priority: 0, + mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, + }); + if (steps < 0 && this.data.power) { + changes.push({ + key: 'system.stats.toughness.value', + value: steps * -1, + priority: 0, + mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, + }); + } else { + changes.push({ + key: 'system.attributes.strength.die.sides', + value: steps * 2, + priority: 0, + mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, + }); + } + return changes; + } + + get effectName() { + if (this.data.steps >= 0) { + return 'Growth'; + } + return 'Shrink'; + } + + get description() { + let text = super.description; + if (this.data.steps >= 0) { + text += `

Grow the target by ${this.data.steps} steps.

`; + } else { + text += `

Shrink the target by ${this.data.steps} steps`; + if (this.data.power) { + text += ' while retaining Strength and Toughness'; + } + text += '.

'; + } + return text; + } } diff --git a/src/module/powers/powers.js b/src/module/powers/powers.js index 4ea1fc1..bf53fbf 100644 --- a/src/module/powers/powers.js +++ b/src/module/powers/powers.js @@ -28,6 +28,7 @@ import { EnvironmentalProtectionEffect } from './environmentalProtection.js'; import { FarsightEffect } from './farsight.js'; import { FearEffect } from './fear.js'; import { FlyEffect } from './fly.js'; +import { GrowthShrinkEffect } from './growthShrink.js'; const PowerClasses = { 'arcane-protection': ArcaneProtectionEffect, @@ -37,8 +38,8 @@ const PowerClasses = { blast: BlastEffect, blind: BlindEffect, bolt: BoltEffect, - 'boostlower-trait': BoostLowerTraitEffect, 'boost-lower-trait': BoostLowerTraitEffect, + 'boostlower-trait': BoostLowerTraitEffect, 'boost-trait': BoostLowerTraitEffect, burrow: BurrowEffect, burst: BurstEffect, @@ -63,7 +64,11 @@ const PowerClasses = { farsight: FarsightEffect, fear: FearEffect, fly: FlyEffect, + growth: GrowthShrinkEffect, + 'growth-shrink': GrowthShrinkEffect, + growthshrink: GrowthShrinkEffect, 'lower-trait': BoostLowerTraitEffect, + shrink: GrowthShrinkEffect, }; /* ---------------------------------------------------------------- */ diff --git a/src/templates/powerDialog.html b/src/templates/powerDialog.html index 30d3dd7..79e1e39 100644 --- a/src/templates/powerDialog.html +++ b/src/templates/powerDialog.html @@ -6,6 +6,11 @@

Apply the affects of {{name}}.

+ {{#if extraDescription }} +
+ {{{extraDescription}}} +
+ {{/if}} {{#if basePowerPoints}}

Base Power Points: {{basePowerPoints}} {{/if}} @@ -33,7 +38,13 @@ {{/if}} {{#if isNumber}} - + {{/if}} {{#if isSelect}}