Begin implementation of the Stats / Skills tab
This commit is contained in:
parent
753d72b4e0
commit
0e8d1615a7
16 changed files with 292 additions and 64 deletions
|
|
@ -1,6 +1,11 @@
|
|||
export const statDice = [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
|
||||
|
||||
export const trainingLevels = [``, `locked`, `+2`, `+4`];
|
||||
export const trainingLevels = {
|
||||
locked: -1,
|
||||
untrained: 0,
|
||||
trained: 2,
|
||||
expert: 4
|
||||
}
|
||||
|
||||
export const damageTypes = [ `slashing`, `piercing`, `smashing`, `gun`, `neon`, `shadow`, `solar` ];
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export const partials = [
|
|||
`partials/panel.hbs`,
|
||||
`items/aspect.hbs`,
|
||||
|
||||
// All of the partials for the PC sheet panels
|
||||
// All of the partials for the PC MVP sheet panels
|
||||
`actors/char-sheet-mvp/panels/aspect.pc.hbs`,
|
||||
`actors/char-sheet-mvp/panels/backpack.pc.hbs`,
|
||||
`actors/char-sheet-mvp/panels/mounts.pc.hbs`,
|
||||
|
|
@ -18,6 +18,9 @@ export const partials = [
|
|||
`actors/char-sheet-mvp/panels/pets.pc.hbs`,
|
||||
`actors/char-sheet-mvp/panels/sync.pc.hbs`,
|
||||
`actors/char-sheet-mvp/panels/weapons.pc.hbs`,
|
||||
|
||||
// The v2 PC sheet partials
|
||||
`actors/char-sheet/v2/partials/stats.v2.pc.hbs`,
|
||||
];
|
||||
|
||||
export const icons = [
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { createArray } from "./createArray.mjs";
|
|||
import { detailsExpanded } from "./detailsExpanded.mjs";
|
||||
import { objectValue } from "./objectValue.mjs";
|
||||
import { toFriendlyDuration } from "./toFriendlyDuration.mjs";
|
||||
import { localizer } from "../utils/localizer.mjs";
|
||||
|
||||
export default {
|
||||
|
||||
|
|
@ -12,6 +13,7 @@ export default {
|
|||
"dd-toFriendlyDuration": toFriendlyDuration,
|
||||
"dd-objectValue": objectValue,
|
||||
"dd-expanded": detailsExpanded,
|
||||
"dd-i18n": localizer,
|
||||
|
||||
// Simple helpers
|
||||
"dd-stringify": v => JSON.stringify(v, null, ` `),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { MappingField } from "../fields/MappingField.mjs";
|
||||
import DOTDUNGEON from "../../config.mjs";
|
||||
|
||||
function diceChoiceField() {
|
||||
return new foundry.data.fields.StringField({
|
||||
|
|
@ -6,17 +7,17 @@ function diceChoiceField() {
|
|||
blank: true,
|
||||
trim: true,
|
||||
options() {
|
||||
return CONFIG.DOTDUNGEON.statDice;
|
||||
return DOTDUNGEON.statDice;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
function trainingLevelField() {
|
||||
return new foundry.data.fields.StringField({
|
||||
initial: ``,
|
||||
blank: true,
|
||||
trim: true,
|
||||
options: CONFIG.DOTDUNGEON.trainingLevels,
|
||||
return new foundry.data.fields.NumberField({
|
||||
initial: 0,
|
||||
min: -1,
|
||||
integer: true,
|
||||
options: Object.values(DOTDUNGEON.trainingLevels),
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ function weaponDamageTypeField() {
|
|||
return new foundry.data.fields.StringField({
|
||||
initial: ``,
|
||||
blank: true,
|
||||
options: [ ``, ...CONFIG.DOTDUNGEON.damageTypes ],
|
||||
options: [ ``, ...DOTDUNGEON.damageTypes ],
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ function ammoTypeField() {
|
|||
return new foundry.data.fields.StringField({
|
||||
initial: ``,
|
||||
blank: true,
|
||||
options: [ ``, ...CONFIG.DOTDUNGEON.ammoTypes ],
|
||||
options: [ ``, ...DOTDUNGEON.ammoTypes ],
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -40,6 +41,14 @@ export class PlayerData extends foundry.abstract.TypeDataModel {
|
|||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
/*
|
||||
These are special data properties that will be used by ActiveEffects
|
||||
to modify certain limits within the actor, allowing for neat hacks
|
||||
that change these
|
||||
*/
|
||||
weapon_slots: new fields.NumberField({ initial: 2 }),
|
||||
inventory_slots: new fields.NumberField({ initial: 0 }),
|
||||
|
||||
bytes: new fields.NumberField({
|
||||
initial: 0,
|
||||
min: 0,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
18
module/utils/modifierToString.mjs
Normal file
18
module/utils/modifierToString.mjs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Takes in an integer and converts it into a string format that can be used in
|
||||
* roll formulas or for displaying to the user.
|
||||
*
|
||||
* @param {number} mod The modifier to stringify
|
||||
* @param {object} opts
|
||||
* @param {boolean} opts.spaces Puts spaces on either side of the operand
|
||||
* @returns {string}
|
||||
*/
|
||||
export function modifierToString(mod, opts = {}) {
|
||||
if (mod == 0) return ``;
|
||||
|
||||
let value = [``, `+`, mod]
|
||||
if (mod < 0) {
|
||||
value = [``, `-`, Math.abs(mod)]
|
||||
};
|
||||
return value.join(opts.spaces ? ` ` : ``);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue