mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-14 04:31:07 +01:00
Merged with data-models-structure branch
This commit is contained in:
commit
d1c968d0a2
62 changed files with 1760 additions and 956 deletions
|
|
@ -9,6 +9,12 @@ export default class DhpItem extends Item {
|
|||
return super.getEmbeddedDocument(embeddedName, id, { invalid, strict });
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
prepareEmbeddedDocuments() {
|
||||
super.prepareEmbeddedDocuments();
|
||||
for (const action of this.system.actions ?? []) action.prepareData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @param {object} options - Options which modify the getRollData method.
|
||||
|
|
@ -92,4 +98,47 @@ export default class DhpItem extends Item {
|
|||
options
|
||||
});
|
||||
}
|
||||
|
||||
async selectActionDialog() {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/views/actionSelect.hbs',
|
||||
{ actions: this.system.actions }
|
||||
),
|
||||
title = 'Select Action',
|
||||
type = 'div',
|
||||
data = {};
|
||||
return Dialog.prompt({
|
||||
title,
|
||||
// label: title,
|
||||
content,
|
||||
type,
|
||||
callback: html => {
|
||||
const form = html[0].querySelector('form'),
|
||||
fd = new foundry.applications.ux.FormDataExtended(form);
|
||||
return this.system.actions.find(a => a._id === fd.object.actionId);
|
||||
},
|
||||
rejectClose: false
|
||||
});
|
||||
}
|
||||
|
||||
async use(event) {
|
||||
const actions = this.system.actions;
|
||||
let response;
|
||||
if (actions?.length) {
|
||||
let action = actions[0];
|
||||
if (actions.length > 1 && !event?.shiftKey) {
|
||||
// Actions Choice Dialog
|
||||
action = await this.selectActionDialog();
|
||||
}
|
||||
if (action) response = action.use(event);
|
||||
// Check Target
|
||||
// If action.roll => Roll Dialog
|
||||
// Else If action.cost => Cost Dialog
|
||||
// Then
|
||||
// Apply Cost
|
||||
// Apply Effect
|
||||
}
|
||||
// Display Item Card in chat
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue