Get 95% of the way through the stats tab

This commit is contained in:
Oliver-Akins 2024-03-01 23:28:18 -07:00
parent 7516e7b42b
commit c1ee1a9ef8
7 changed files with 91 additions and 46 deletions

View file

@ -1,11 +1,11 @@
export const statDice = [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
export const trainingLevels = {
locked: -1,
untrained: 0,
trained: 2,
expert: 4
}
export const trainingLevels = [
{ key: "locked", label: "dotdungeon.trainingLevel.locked", value: -1 },
{ key: "untrained", label: "dotdungeon.trainingLevel.untrained", value: 0 },
{ key: "trained", label: "dotdungeon.trainingLevel.trained", value: 2 },
{ key: "expert", label: "dotdungeon.trainingLevel.expert", value: 4 },
];
export const damageTypes = [ `slashing`, `piercing`, `smashing`, `gun`, `neon`, `shadow`, `solar` ];
@ -32,6 +32,7 @@ export const skills = {
hands: handsSkills,
};
export const defaultItemTier = `simple`;
export const itemTiers = [
`simple`, `greater`,
`rare`, `legendary`
@ -64,6 +65,7 @@ export default {
handsSkills,
allSkills,
skills,
defaultItemTier,
itemTiers,
syncMilestones,
syncDice,

View file

@ -1,3 +1,5 @@
import { localizer } from "../utils/localizer.mjs";
/**
* @typedef {object} Option
* @property {string} [label]
@ -9,7 +11,8 @@
* @param {string | number} selected
* @param {Array<Option | string>} opts
*/
export function options(selected, opts) {
export function options(selected, opts, meta) {
const { localize = false } = meta.hash;
selected = Handlebars.escapeExpression(selected);
const htmlOptions = [];
@ -24,7 +27,7 @@ export function options(selected, opts) {
${selected === opt.value ? "selected" : ""}
${opt.disabled ? "disabled" : ""}
>
${opt.label}
${localize ? localizer(opt.label) : opt.label}
</option>`
);
};

View file

@ -64,13 +64,16 @@ export class PlayerSheetv2 extends GenericActorSheet {
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,
};
});
stat.dieOptions = [
{ label: `---`, value: `` },
...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
@ -81,10 +84,10 @@ export class PlayerSheetv2 extends GenericActorSheet {
const value = this.actor.system.skills[statName][skill];
stat.skills.push({
key: skill,
name: localizer(`dotdungeon.skills.${skill}`),
name: game.i18n.format(`dotdungeon.skills.${skill}`),
value,
formula: `1` + stat.value + modifierToString(value),
rollDisabled: stat.value === `` || value === `locked`,
formula: `1` + stat.value + modifierToString(value, { spaces: true }),
rollDisabled: stat.value === `` || value === -1,
});
};