This commit is contained in:
WBHarry 2026-01-15 18:35:24 +01:00
parent 3040924609
commit 89f350a013
3 changed files with 42 additions and 53 deletions

View file

@ -1,41 +1,41 @@
//Setting RollTable
//import DhRollTableData from 'systems/daggerheart/module/data/rollTable.mjs';
export default class DhRollTableSheet extends foundry.applications.sheets.RollTableSheet { export default class DhRollTableSheet extends foundry.applications.sheets.RollTableSheet {
static buildParts() {
const { footer, ...parts } = super.PARTS;
return {
...parts,
summary: { template: 'systems/daggerheart/templates/sheets/rollTable/summary.hbs' },
footer
}
}
static PARTS = DhRollTableSheet.buildParts();
static DEFAULT_OPTIONS = { static DEFAULT_OPTIONS = {
...super.DEFAULT_OPTIONS, ...super.DEFAULT_OPTIONS,
classes: ['daggerheart', 'sheet', 'dh-style'], actions: {
actions : {
addAltFormula: DhRollTableSheet.#onAddAltFormula, addAltFormula: DhRollTableSheet.#onAddAltFormula,
removeAltFormula: DhRollTableSheet.#onRemoveAltFormula removeAltFormula: DhRollTableSheet.#onRemoveAltFormula
} }
}; };
static buildParts() {
const { footer, ...parts } = super.PARTS;
const test = {
...parts,
summary: { template: 'systems/daggerheart/templates/sheets/rollTable/summary.hbs' },
footer
};
return test;
}
static PARTS = DhRollTableSheet.buildParts();
async _preparePartContext(partId, context, options) { async _preparePartContext(partId, context, options) {
context = await super._preparePartContext(partId,context,options); context = await super._preparePartContext(partId, context, options);
switch(partId) {
switch (partId) {
case 'summary': case 'summary':
context.flagData = this.daggerheartFlag context.flagData = this.daggerheartFlag;
break; break;
} }
return context; return context;
} }
async _preRender(context,options) { async _preRender(context, options) {
await super._preFirstRender(context,options); await super._preRender(context, options);
if (!options.internalReferesh) if (!options.internalReferesh)
this.daggerheartFlag = new game.system.api.data.scenes.DHScene(this.document.flags.daggerheart) this.daggerheartFlag = new game.system.api.data.DhRollTable(this.document.flags.daggerheart);
} }
/** @override */ /** @override */
@ -44,19 +44,8 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
super._processSubmitData(event, form, submitData, options); super._processSubmitData(event, form, submitData, options);
} }
static actions = {
addAltFormula: DhRollTableSheet.#onAddAltFormula,
removeAltFormula: DhRollTableSheet.#onRemoveAltFormula
};
//Add formulafield static async #onAddAltFormula(_event, target) {}
static async #onAddAltFormula(event, target) {
}
//Remove formulafield static async #onRemoveAltFormula(_event, target) {}
static async #onRemoveAltFormula(event, target) {
}
} }

View file

@ -1,6 +1,7 @@
export { default as DhCombat } from './combat.mjs'; export { default as DhCombat } from './combat.mjs';
export { default as DhCombatant } from './combatant.mjs'; export { default as DhCombatant } from './combatant.mjs';
export { default as DhTagTeamRoll } from './tagTeamRoll.mjs'; export { default as DhTagTeamRoll } from './tagTeamRoll.mjs';
export { default as DhRollTable } from './rollTable.mjs';
export * as countdowns from './countdowns.mjs'; export * as countdowns from './countdowns.mjs';
export * as actions from './action/_module.mjs'; export * as actions from './action/_module.mjs';

View file

@ -1,28 +1,27 @@
import FormulaField from './fields/formulaField.mjs';
//Extra definitions for RollTable //Extra definitions for RollTable
export default class DhRollTableData extends foundry.abstract.TypeDataModel { export default class DhRollTable extends foundry.abstract.TypeDataModel {
static defineSchema(){ static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return{ return {
formulaName: new fields.StringField({ // This is to give a name to go together with the core.formula formulaName: new fields.StringField({
required:true, // This is to give a name to go together with the core.formula
nullable: false, required: true,
initial: 'Formula' // Should be a translation nullable: false,
initial: 'Formula' // Should be a translation
}), }),
altFormula: new fields.ArrayField( altFormula: new fields.ArrayField(
new fields.SchemaField({ new fields.SchemaField({
key: new fields.StringField({ key: new fields.StringField({
required:false, required: false,
nullable:false, nullable: false,
blank:true blank: true
}), }),
formula: new fields.StringField({ formula: new FormulaField()
required:true,
blank:false,
initial:"1d4" //Filler value
})
}) })
) )
} };
} }
} }