mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Refactor/actions v2 (#402)
* Action Refactor Part #1 * Fixed Weapon/Armor features. Fixed Feature actions * f * Action Refactor Part #2 * Fixes * Remove ActionsField from Companion * Fixes * Localization fix * BaseDataItem hasActions false --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
80744381f5
commit
0632a8c6bb
52 changed files with 988 additions and 743 deletions
|
|
@ -9,6 +9,23 @@ export default class DHItem extends foundry.documents.Item {
|
|||
for (const action of this.system.actions ?? []) action.prepareData();
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
getEmbeddedDocument(embeddedName, id, options) {
|
||||
let doc;
|
||||
switch (embeddedName) {
|
||||
case 'Action':
|
||||
doc = this.system.actions?.get(id);
|
||||
if (!doc && this.system.attack?.id === id) doc = this.system.attack;
|
||||
break;
|
||||
default:
|
||||
return super.getEmbeddedDocument(embeddedName, id, options);
|
||||
}
|
||||
if (options?.strict && !doc) {
|
||||
throw new Error(`The key ${id} does not exist in the ${embeddedName} Collection`);
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @param {object} options - Options which modify the getRollData method.
|
||||
|
|
@ -106,10 +123,10 @@ export default class DHItem extends foundry.documents.Item {
|
|||
}
|
||||
|
||||
async use(event) {
|
||||
const actions = this.system.actionsList;
|
||||
if (actions?.length) {
|
||||
let action = actions[0];
|
||||
if (actions.length > 1 && !event?.shiftKey) {
|
||||
const actions = new Set(this.system.actionsList);
|
||||
if (actions?.size) {
|
||||
let action = actions.first();
|
||||
if (actions.size > 1 && !event?.shiftKey) {
|
||||
// Actions Choice Dialog
|
||||
action = await this.selectActionDialog(event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue