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 { HandlebarsApplicationMixin } = foundry.applications.api;
const { ActorSheetV2 } = foundry.applications.sheets; const { ActorSheetV2 } = foundry.applications.sheets;
const { ContextMenu } = foundry.applications.ui; const { ContextMenu } = foundry.applications.ui;
const { deepClone } = foundry.utils;
export class HeroCraftCardV1 extends GenericAppMixin(HandlebarsApplicationMixin(ActorSheetV2)) { 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 = await super._preparePartContext(partId, ctx, opts);
ctx.actor = this.document; ctx.actor = this.document;
ctx = await HeroCraftCardV1.prepareAura(ctx);
ctx = await HeroCraftCardV1.prepareCraft(ctx); ctx = await HeroCraftCardV1.prepareCraft(ctx);
Logger.debug(`Context:`, ctx); Logger.debug(`Context:`, ctx);
return 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) { static async prepareCraft(ctx) {
ctx.craft = {}; ctx.craft = {};
const aspects = Object.values(gameTerms.Aspects); const aspects = Object.values(gameTerms.Aspects);

View file

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

View file

@ -1,5 +1,6 @@
import { derivedMaximumBar } from "../helpers.mjs"; import { derivedMaximumBar } from "../helpers.mjs";
import { gameTerms } from "../../gameTerms.mjs"; import { gameTerms } from "../../gameTerms.mjs";
import { rankToInteger } from "../../utils/rank.mjs";
import { sumReduce } from "../../utils/sumReduce.mjs"; import { sumReduce } from "../../utils/sumReduce.mjs";
const { fields } = foundry.data; const { fields } = foundry.data;
@ -122,6 +123,13 @@ export class HeroData extends foundry.abstract.TypeDataModel {
prepareBaseData() { prepareBaseData() {
super.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; this.guts.max = 0;
// The limitations imposed on things like inventory spaces and equipped // 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;
};

View file

@ -14,11 +14,11 @@
></rc-svg> ></rc-svg>
<div class="aura-values"> <div class="aura-values">
<div class="dual-pill"> <div class="dual-pill">
<span class="label">Aura</span> <span class="label" aria-hidden="true">Aura</span>
<div class="values"> <div class="values">
<span class="value"></span> <span class="value">{{aura.normal}}</span>
<span class="slash" aria-hidden="true"></span> <span class="slash" aria-hidden="true"></span>
<span class="value"></span> <span class="value">{{aura.heavy}}</span>
</div> </div>
</div> </div>
</div> </div>