Guts Data Un-saving
Don't save guts max to database since we don't need it, but make sure that it still shows up as a token bar that can be chosen rather than a single value
This commit is contained in:
parent
514a643b32
commit
f1d0d781d8
3 changed files with 37 additions and 2 deletions
|
|
@ -1,9 +1,27 @@
|
||||||
import { barAttribute } from "../helpers.mjs";
|
|
||||||
import { gameTerms } from "../../gameTerms.mjs";
|
import { gameTerms } from "../../gameTerms.mjs";
|
||||||
|
import { sumReduce } from "../../utils/sumReduce.mjs";
|
||||||
|
|
||||||
const { fields } = foundry.data;
|
const { fields } = foundry.data;
|
||||||
|
|
||||||
export class HeroData extends foundry.abstract.TypeDataModel {
|
export class HeroData extends foundry.abstract.TypeDataModel {
|
||||||
|
|
||||||
|
static get trackableAttributes() {
|
||||||
|
return {
|
||||||
|
bar: [
|
||||||
|
`guts`,
|
||||||
|
],
|
||||||
|
value: [
|
||||||
|
`ability.grit`,
|
||||||
|
`ability.gait`,
|
||||||
|
`ability.grip`,
|
||||||
|
`ability.glim`,
|
||||||
|
`level.glory`,
|
||||||
|
`level.step`,
|
||||||
|
`level.rank`,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
return {
|
return {
|
||||||
ability: new fields.SchemaField({
|
ability: new fields.SchemaField({
|
||||||
|
|
@ -36,7 +54,14 @@ export class HeroData extends foundry.abstract.TypeDataModel {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
guts: barAttribute(0, 5),
|
guts: new fields.SchemaField({
|
||||||
|
value: new fields.NumberField({
|
||||||
|
min: 0,
|
||||||
|
initial: 5,
|
||||||
|
integer: true,
|
||||||
|
nullable: false,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
coin: new fields.SchemaField({
|
coin: new fields.SchemaField({
|
||||||
gold: new fields.NumberField({
|
gold: new fields.NumberField({
|
||||||
initial: 5,
|
initial: 5,
|
||||||
|
|
@ -97,6 +122,8 @@ export class HeroData extends foundry.abstract.TypeDataModel {
|
||||||
prepareBaseData() {
|
prepareBaseData() {
|
||||||
super.prepareBaseData();
|
super.prepareBaseData();
|
||||||
|
|
||||||
|
this.guts.max = 0;
|
||||||
|
|
||||||
// The limitations imposed on things like inventory spaces and equipped
|
// The limitations imposed on things like inventory spaces and equipped
|
||||||
// weapon count
|
// weapon count
|
||||||
this.limit = {
|
this.limit = {
|
||||||
|
|
@ -108,6 +135,8 @@ export class HeroData extends foundry.abstract.TypeDataModel {
|
||||||
prepareDerivedData() {
|
prepareDerivedData() {
|
||||||
super.prepareDerivedData();
|
super.prepareDerivedData();
|
||||||
|
|
||||||
|
this.guts.max += Object.values(this.ability).reduce(sumReduce);
|
||||||
|
|
||||||
// Movement speeds
|
// Movement speeds
|
||||||
this.speed = {
|
this.speed = {
|
||||||
move: this.ability.gait + 3,
|
move: this.ability.gait + 3,
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,8 @@ Hooks.once(`init`, () => {
|
||||||
// #endregion
|
// #endregion
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
// #region Token Attrs
|
||||||
|
CONFIG.Actor.trackableAttributes.hero = HeroData.trackableAttributes;
|
||||||
|
|
||||||
Handlebars.registerHelper(helpers);
|
Handlebars.registerHelper(helpers);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
3
module/utils/sumReduce.mjs
Normal file
3
module/utils/sumReduce.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export function sumReduce(sum, val) {
|
||||||
|
return sum + val;
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue