Add the derived data for the aura ranges

This commit is contained in:
Oliver-Akins 2025-03-09 00:16:21 -07:00
parent 89b51a01e6
commit 4f35db01b6
5 changed files with 54 additions and 3 deletions

View file

@ -8,6 +8,7 @@ import { Logger } from "../../utils/Logger.mjs";
const { HandlebarsApplicationMixin } = foundry.applications.api;
const { ActorSheetV2 } = foundry.applications.sheets;
const { ContextMenu } = foundry.applications.ui;
const { deepClone } = foundry.utils;
export class HeroCraftCardV1 extends GenericAppMixin(HandlebarsApplicationMixin(ActorSheetV2)) {
@ -79,12 +80,46 @@ export class HeroCraftCardV1 extends GenericAppMixin(HandlebarsApplicationMixin(
ctx = await super._preparePartContext(partId, ctx, opts);
ctx.actor = this.document;
ctx = await HeroCraftCardV1.prepareAura(ctx);
ctx = await HeroCraftCardV1.prepareCraft(ctx);
Logger.debug(`Context:`, ctx);
return ctx;
};
static async prepareAura(ctx) {
const { normal, heavy } = ctx.aura = deepClone(ctx.actor.system.aura);
ctx.auraClasses = {};
if (heavy >= 4) {
ctx.auraClasses.four = `heavy`;
}
if (heavy >= 6) {
ctx.auraClasses.six = `heavy`;
}
if (heavy >= 8) {
ctx.auraClasses.eight = `heavy`;
}
if (heavy >= 10) {
ctx.auraClasses.ten = `heavy`;
}
if (normal >= 4) {
ctx.auraClasses.four = `normal`;
}
if (normal >= 6) {
ctx.auraClasses.six = `normal`;
}
if (normal >= 8) {
ctx.auraClasses.eight = `normal`;
}
if (normal >= 10) {
ctx.auraClasses.ten = `normal`;
}
return ctx;
};
static async prepareCraft(ctx) {
ctx.craft = {};
const aspects = Object.values(gameTerms.Aspects);