Fixed Weapon/Armor features. Fixed Feature actions

This commit is contained in:
WBHarry 2025-07-23 00:37:25 +02:00
parent 5243260b4d
commit 920ab3fd76
10 changed files with 84 additions and 63 deletions

View file

@ -12,15 +12,15 @@ export default class DHItem extends foundry.documents.Item {
/** @inheritDoc */
getEmbeddedDocument(embeddedName, id, options) {
let doc;
switch ( embeddedName ) {
case "Action":
switch (embeddedName) {
case 'Action':
doc = this.system.actions?.get(id);
if(!doc && this.system.attack?.id === id) doc = this.system.attack;
if (!doc && this.system.attack?.id === id) doc = this.system.attack;
break;
default:
return super.getEmbeddedDocument(embeddedName, id, options);
}
if ( options?.strict && !doc ) {
if (options?.strict && !doc) {
throw new Error(`The key ${id} does not exist in the ${embeddedName} Collection`);
}
return doc;
@ -124,9 +124,9 @@ 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) {
if (actions?.size) {
let action = actions.contents[0];
if (actions.size > 1 && !event?.shiftKey) {
// Actions Choice Dialog
action = await this.selectActionDialog(event);
}