actions types - attack roll

This commit is contained in:
Dapoolp 2025-06-10 23:41:25 +02:00
parent 4c7f3a02c4
commit edaf5df9e0
35 changed files with 1015 additions and 165 deletions

View file

@ -11,6 +11,13 @@ export default class DhpItem extends Item {
// this.system.domains = CONFIG.daggerheart.DOMAIN.classDomainMap[Object.keys(CONFIG.daggerheart.DOMAIN.classDomainMap).find(x => x === this.name.toLowerCase())];
}
}
/** @inheritDoc */
prepareEmbeddedDocuments() {
super.prepareEmbeddedDocuments();
for ( const action of this.system.actions ?? [] ) action.prepareData();
// for ( const action of this.system.actions ?? [] ) console.log(action);
}
/**
* @inheritdoc
@ -99,4 +106,46 @@ 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;
if(actions?.length) {
let action = actions[0];
if(actions.length > 1 && !event?.shiftKey) {
// Actions Choice Dialog
action = await this.selectActionDialog();
}
if(!action) return;
// Check Target
// If action.roll => Roll Dialog
// Else If action.cost => Cost Dialog
// Then
// Apply Cost
// Apply Effect
return action.use(event);
}
// Display Item Card in chat
}
}