mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-14 12:41:07 +01:00
Feature/112 items use action datamodel (#127)
* Create new actions classes * actions types - attack roll * fixes before merge * First PR * Add daggerheart.css to gitignore * Update ToDo * Remove console log * Fixed chat /dr roll * Remove jQuery * Fixed so the different chat themes work again * Fixed duality roll buttons * Fix to advantage/disadvantage shortcut * Extand action to other item types * Roll fixes * Fixes to adversary rolls * resources * Fixed adversary dice --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
d6acbcb281
commit
3a0a4673ad
62 changed files with 1712 additions and 933 deletions
|
|
@ -2,6 +2,12 @@ export default class DhpItem extends Item {
|
|||
prepareData() {
|
||||
super.prepareData();
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
prepareEmbeddedDocuments() {
|
||||
super.prepareEmbeddedDocuments();
|
||||
for ( const action of this.system.actions ?? [] ) action.prepareData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
|
@ -90,4 +96,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
|
||||
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