Begin implementation of the Stats / Skills tab

This commit is contained in:
Oliver-Akins 2024-02-29 22:35:28 -07:00
parent 753d72b4e0
commit 0e8d1615a7
16 changed files with 292 additions and 64 deletions

View file

@ -1,4 +1,7 @@
import { GenericActorSheet } from "../../GenericActorSheet.mjs";
import DOTDUNGEON from "../../../config.mjs";
import { localizer } from "../../../utils/localizer.mjs";
import { modifierToString } from "../../../utils/modifierToString.mjs";
export class PlayerSheetv2 extends GenericActorSheet {
static get defaultOptions() {
@ -10,8 +13,8 @@ export class PlayerSheetv2 extends GenericActorSheet {
{
group: `page`,
navSelector: `nav`,
contentSelector: `.tab-content`,
initial: `tab1`,
contentSelector: `.page-content`,
initial: `stats`,
},
],
}
@ -40,8 +43,58 @@ export class PlayerSheetv2 extends GenericActorSheet {
ctx.computed = {
canChangeGroup: ctx.settings.playersCanChangeGroup || ctx.isGM,
canAddAspect: !await actor.proxyFunction.bind(actor)(`atAspectLimit`),
stats: this.#statData,
};
console.log(ctx)
return ctx;
};
get #statData() {
const stats = [];
const usedDice = new Set(Object.values(this.actor.system.stats));
for (const statName in this.actor.system.stats) {
const stat = {
key: statName,
name: localizer(`dotdungeon.stat.${statName}`),
value: this.actor.system.stats[statName],
};
/*
Determine what dice are available to the user in the dropdown
selector. Disables all dice options that are selected, but not used
by this stat.
*/
stat.dieOptions = DOTDUNGEON.statDice.map(die => {
return {
value: die,
label: localizer(`dotdungeon.die.${die}`, { stat: statName }),
disabled: usedDice.has(die) && this.actor.system.stats[statName] !== die,
};
});
/*
Calculating the data needed in order to display all of the skills
for this character.
*/
stat.skills = [];
for (const skill in this.actor.system.skills[statName]) {
const value = this.actor.system.skills[statName][skill];
stat.skills.push({
key: skill,
name: localizer(`dotdungeon.skills.${skill}`),
value,
formula: `1` + stat.value + modifierToString(value),
rollDisabled: stat.value === `` || value === `locked`,
});
};
stats.push(stat);
};
return stats;
};
_updateObject(...args) {
console.log(args)
super._updateObject(...args);
};
}