mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
t
This commit is contained in:
parent
1a8cab7ab6
commit
57aa2afbbe
1 changed files with 34 additions and 15 deletions
|
|
@ -19,6 +19,9 @@ const fields = foundry.data.fields;
|
||||||
|
|
||||||
export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel) {
|
export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel) {
|
||||||
static extraSchemas = ['cost', 'uses', 'range'];
|
static extraSchemas = ['cost', 'uses', 'range'];
|
||||||
|
// static schemaFields = new Map();
|
||||||
|
static schemaFields = [];
|
||||||
|
// static workflow = [];
|
||||||
|
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const schemaFields = {
|
const schemaFields = {
|
||||||
|
|
@ -38,9 +41,18 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
|
|
||||||
this.extraSchemas.forEach(s => {
|
this.extraSchemas.forEach(s => {
|
||||||
let clsField;
|
let clsField;
|
||||||
if ((clsField = this.getActionField(s))) schemaFields[s] = new clsField();
|
if ((clsField = this.getActionField(s))) {
|
||||||
|
// this.schemaFields.set(s, clsField);
|
||||||
|
this.schemaFields.push(clsField);
|
||||||
|
schemaFields[s] = new clsField();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.schemaFields.sort((a, b) => a.order - b.order);
|
||||||
|
|
||||||
|
// this.prepareWorkflow();
|
||||||
|
console.log(this.schemaFields);
|
||||||
|
|
||||||
return schemaFields;
|
return schemaFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,21 +123,26 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
return actorData;
|
return actorData;
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareWorkflow(workflow) {
|
// static prepareWorkflow() {
|
||||||
for (let i = 0; i < this.constructor.extraSchemas.length; i++) {
|
// this.schemaFields.forEach( clsField => {
|
||||||
let clsField = this.constructor.getActionField(this.constructor.extraSchemas[i]);
|
// if (clsField?.execute)
|
||||||
|
// this.workflow.push({ order: clsField.order, exec: clsField.execute});
|
||||||
|
// })
|
||||||
|
/* for (let i = 0; i < this.constructor.extraSchemas.length; i++) {
|
||||||
|
// let clsField = this.constructor.getActionField(this.constructor.extraSchemas[i]);
|
||||||
|
let clsField = this.constructor.schemaFields.get(this.constructor.extraSchemas[i]);
|
||||||
if (clsField?.execute) {
|
if (clsField?.execute) {
|
||||||
workflow.push({ order: clsField.order, exec: clsField.execute});
|
workflow.push({ order: clsField.order, exec: clsField.execute});
|
||||||
// const keep = clsField.prepareConfig.call(this, config);
|
// const keep = clsField.prepareConfig.call(this, config);
|
||||||
// if (config.isFastForward && !keep) return;
|
// if (config.isFastForward && !keep) return;
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
workflow.sort((a, b) => a.order - b.order);
|
// this.workflow.sort((a, b) => a.order - b.order);
|
||||||
}
|
// }
|
||||||
|
|
||||||
async executeWorkflow(workflow, config) {
|
async executeWorkflow(config) {
|
||||||
console.log(workflow)
|
console.log(this.constructor.workflow)
|
||||||
for(const part of workflow) {
|
for(const part of this.constructor.workflow) {
|
||||||
console.log(part)
|
console.log(part)
|
||||||
if(await part.exec.call(this, config) === false) return;
|
if(await part.exec.call(this, config) === false) return;
|
||||||
}
|
}
|
||||||
|
|
@ -137,13 +154,15 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
if (this.chatDisplay) await this.toChat();
|
if (this.chatDisplay) await this.toChat();
|
||||||
let { byPassRoll } = options,
|
let { byPassRoll } = options,
|
||||||
config = this.prepareConfig(event, byPassRoll);
|
config = this.prepareConfig(event, byPassRoll);
|
||||||
for (let i = 0; i < this.constructor.extraSchemas.length; i++) {
|
// for (let i = 0; i < this.constructor.extraSchemas.length; i++) {
|
||||||
let clsField = this.constructor.getActionField(this.constructor.extraSchemas[i]);
|
// let clsField = this.constructor.getActionField(this.constructor.extraSchemas[i]);
|
||||||
|
// let clsField = this.constructor.schemaFields.get(this.constructor.extraSchemas[i]);
|
||||||
|
this.constructor.schemaFields.forEach( clsField => {
|
||||||
if (clsField?.prepareConfig) {
|
if (clsField?.prepareConfig) {
|
||||||
const keep = clsField.prepareConfig.call(this, config);
|
const keep = clsField.prepareConfig.call(this, config);
|
||||||
if (config.isFastForward && !keep) return;
|
if (config.isFastForward && !keep) return;
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
|
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
|
||||||
|
|
||||||
|
|
@ -155,8 +174,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
|
|
||||||
const workflow = [];
|
const workflow = [];
|
||||||
|
|
||||||
this.prepareWorkflow(workflow);
|
// this.prepareWorkflow(workflow);
|
||||||
await this.executeWorkflow(workflow, config);
|
await this.executeWorkflow(config);
|
||||||
|
|
||||||
// if (config.hasRoll) {
|
// if (config.hasRoll) {
|
||||||
// const rollConfig = this.prepareRoll(config);
|
// const rollConfig = this.prepareRoll(config);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue