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);

View file

@ -8,6 +8,7 @@ import { RichEditor } from "./Apps/RichEditor.mjs";
// Util imports
import { distanceBetweenFates, nextFate, previousFate } from "./utils/fates.mjs";
import { documentSorter } from "./consts.mjs";
import { rankToInteger } from "./utils/rank.mjs";
const { deepFreeze } = foundry.utils;
@ -28,6 +29,7 @@ Object.defineProperty(
distanceBetweenFates,
nextFate,
previousFate,
rankToInteger,
},
}),
writable: false,

View file

@ -1,5 +1,6 @@
import { derivedMaximumBar } from "../helpers.mjs";
import { gameTerms } from "../../gameTerms.mjs";
import { rankToInteger } from "../../utils/rank.mjs";
import { sumReduce } from "../../utils/sumReduce.mjs";
const { fields } = foundry.data;
@ -122,6 +123,13 @@ export class HeroData extends foundry.abstract.TypeDataModel {
prepareBaseData() {
super.prepareBaseData();
// Calculate the person's base Crafting aura
const rank = rankToInteger(this.level.rank);
this.aura = {
normal: ( rank + 1 ) * 2,
heavy: ( rank + 2 ) * 2,
};
this.guts.max = 0;
// The limitations imposed on things like inventory spaces and equipped

6
module/utils/rank.mjs Normal file
View file

@ -0,0 +1,6 @@
import { gameTerms } from "../gameTerms.mjs";
export function rankToInteger(rankName) {
return Object.values(gameTerms.Rank)
.findIndex(r => r === rankName) + 1;
};