add growth shrink

This commit is contained in:
2024-05-20 23:01:25 -05:00
parent 36520fcee2
commit ae3bc394e7
4 changed files with 118 additions and 4 deletions
+8
View File
@@ -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';
}
+92 -2
View File
@@ -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 + '<p>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.</p>`;
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 += `<p>Grow the target by ${this.data.steps} steps.</p>`;
} else {
text += `<p>Shrink the target by ${this.data.steps} steps`;
if (this.data.power) {
text += ' while retaining Strength and Toughness';
}
text += '.</p>';
}
return text;
}
}
+6 -1
View File
@@ -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,
};
/* ---------------------------------------------------------------- */