This commit is contained in:
Dapoolp 2025-07-24 23:48:05 +02:00
parent 9da6a13009
commit 192c739a58
13 changed files with 35 additions and 29 deletions

View file

@ -171,7 +171,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
hasEffect: !!this.effects?.length, hasEffect: !!this.effects?.length,
hasSave: this.hasSave, hasSave: this.hasSave,
selectedRollMode: game.settings.get('core', 'rollMode'), selectedRollMode: game.settings.get('core', 'rollMode'),
isFastForward: event.shiftKey || (!this.hasRoll && !this.hasSave), isFastForward: event.shiftKey,
data: this.getRollData() data: this.getRollData()
}; };
} }

View file

@ -49,7 +49,7 @@ export default class DHDamageAction extends DHBaseAction {
const config = { const config = {
title: game.i18n.format('DAGGERHEART.UI.Chat.damageRoll.title', { damage: game.i18n.localize(this.name) }), title: game.i18n.format('DAGGERHEART.UI.Chat.damageRoll.title', { damage: game.i18n.localize(this.name) }),
roll: formulas, roll: formulas,
targets: systemData.targets.filter(t => t.hit) ?? data.targets, targets: systemData.targets?.filter(t => t.hit) ?? data.targets,
hasSave: this.hasSave, hasSave: this.hasSave,
isCritical: systemData.roll?.isCritical ?? false, isCritical: systemData.roll?.isCritical ?? false,
source: systemData.source, source: systemData.source,

View file

@ -1,7 +1,7 @@
import BaseDataActor from './base.mjs'; import BaseDataActor from './base.mjs';
import DhLevelData from '../levelData.mjs'; import DhLevelData from '../levelData.mjs';
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs'; import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
import { ActionField } from '../fields/actionField.mjs'; import { ActionField, ActionsField } from '../fields/actionField.mjs';
import { adjustDice, adjustRange } from '../../helpers/utils.mjs'; import { adjustDice, adjustRange } from '../../helpers/utils.mjs';
import DHCompanionSettings from '../../applications/sheets-configs/companion-settings.mjs'; import DHCompanionSettings from '../../applications/sheets-configs/companion-settings.mjs';
import { resourceField, bonusField } from '../fields/actorField.mjs'; import { resourceField, bonusField } from '../fields/actorField.mjs';
@ -76,7 +76,7 @@ export default class DhCompanion extends BaseDataActor {
} }
} }
}), }),
actions: new fields.ArrayField(new ActionField()), actions: new ActionsField(),
levelData: new fields.EmbeddedDataField(DhLevelData), levelData: new fields.EmbeddedDataField(DhLevelData),
bonuses: new fields.SchemaField({ bonuses: new fields.SchemaField({
damage: new fields.SchemaField({ damage: new fields.SchemaField({

View file

@ -10,5 +10,7 @@ export default class RangeField extends fields.StringField {
super(options, context); super(options, context);
} }
static prepareConfig(config) {} static prepareConfig(config) {
return true;
}
} }

View file

@ -32,7 +32,8 @@ export default class TargetField extends fields.SchemaField {
} }
static checkTargets(amount, targets) { static checkTargets(amount, targets) {
return !amount || (targets.length > amount); return true
// return !amount || (targets.length > amount);
} }
static isTargetFriendly(target) { static isTargetFriendly(target) {

View file

@ -9,7 +9,8 @@ export default class DHArmor extends AttachableItem {
label: 'TYPES.Item.armor', label: 'TYPES.Item.armor',
type: 'armor', type: 'armor',
hasDescription: true, hasDescription: true,
isInventoryItem: true isInventoryItem: true,
hasActions: true
}); });
} }
@ -38,8 +39,7 @@ export default class DHArmor extends AttachableItem {
baseThresholds: new fields.SchemaField({ baseThresholds: new fields.SchemaField({
major: new fields.NumberField({ integer: true, initial: 0 }), major: new fields.NumberField({ integer: true, initial: 0 }),
severe: new fields.NumberField({ integer: true, initial: 0 }) severe: new fields.NumberField({ integer: true, initial: 0 })
}), })
actions: new ActionsField()
}; };
} }

View file

@ -8,6 +8,8 @@
* @property {boolean} isInventoryItem- Indicates whether items of this type is a Inventory Item * @property {boolean} isInventoryItem- Indicates whether items of this type is a Inventory Item
*/ */
import { ActionsField } from "../fields/actionField.mjs";
const fields = foundry.data.fields; const fields = foundry.data.fields;
export default class BaseDataItem extends foundry.abstract.TypeDataModel { export default class BaseDataItem extends foundry.abstract.TypeDataModel {
@ -69,6 +71,9 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
if (this.metadata.isQuantifiable) if (this.metadata.isQuantifiable)
schema.quantity = new fields.NumberField({ integer: true, initial: 1, min: 0, required: true }); schema.quantity = new fields.NumberField({ integer: true, initial: 1, min: 0, required: true });
if (this.metadata.hasActions)
schema.actions = new ActionsField()
return schema; return schema;
} }

View file

@ -9,7 +9,8 @@ export default class DHConsumable extends BaseDataItem {
type: 'consumable', type: 'consumable',
hasDescription: true, hasDescription: true,
isQuantifiable: true, isQuantifiable: true,
isInventoryItem: true isInventoryItem: true,
hasActions: true
}); });
} }
@ -18,8 +19,7 @@ export default class DHConsumable extends BaseDataItem {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {
...super.defineSchema(), ...super.defineSchema(),
consumeOnUse: new fields.BooleanField({ initial: false }), consumeOnUse: new fields.BooleanField({ initial: false })
actions: new fields.ArrayField(new ActionField())
}; };
} }
} }

View file

@ -8,7 +8,8 @@ export default class DHDomainCard extends BaseDataItem {
label: 'TYPES.Item.domainCard', label: 'TYPES.Item.domainCard',
type: 'domainCard', type: 'domainCard',
hasDescription: true, hasDescription: true,
hasResource: true hasResource: true,
hasActions: true
}); });
} }
@ -29,8 +30,7 @@ export default class DHDomainCard extends BaseDataItem {
required: true, required: true,
initial: CONFIG.DH.DOMAIN.cardTypes.ability.id initial: CONFIG.DH.DOMAIN.cardTypes.ability.id
}), }),
inVault: new fields.BooleanField({ initial: false }), inVault: new fields.BooleanField({ initial: false })
actions: new fields.ArrayField(new ActionField())
}; };
} }

View file

@ -8,7 +8,8 @@ export default class DHFeature extends BaseDataItem {
label: 'TYPES.Item.feature', label: 'TYPES.Item.feature',
type: 'feature', type: 'feature',
hasDescription: true, hasDescription: true,
hasResource: true hasResource: true,
hasActions: true
}); });
} }
@ -24,8 +25,7 @@ export default class DHFeature extends BaseDataItem {
}), }),
subType: new fields.StringField({ choices: CONFIG.DH.ITEM.featureSubTypes, nullable: true, initial: null }), subType: new fields.StringField({ choices: CONFIG.DH.ITEM.featureSubTypes, nullable: true, initial: null }),
originId: new fields.StringField({ nullable: true, initial: null }), originId: new fields.StringField({ nullable: true, initial: null }),
identifier: new fields.StringField(), identifier: new fields.StringField()
actions: new ActionsField()
}; };
} }

View file

@ -9,16 +9,15 @@ export default class DHMiscellaneous extends BaseDataItem {
type: 'miscellaneous', type: 'miscellaneous',
hasDescription: true, hasDescription: true,
isQuantifiable: true, isQuantifiable: true,
isInventoryItem: true isInventoryItem: true,
hasActions: true
}); });
} }
/** @inheritDoc */ /** @inheritDoc */
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields;
return { return {
...super.defineSchema(), ...super.defineSchema()
actions: new fields.ArrayField(new ActionField())
}; };
} }
} }

View file

@ -8,8 +8,8 @@ export default class DHWeapon extends AttachableItem {
label: 'TYPES.Item.weapon', label: 'TYPES.Item.weapon',
type: 'weapon', type: 'weapon',
hasDescription: true, hasDescription: true,
isInventoryItem: true isInventoryItem: true,
// hasInitialAction: true hasActions: true
}); });
} }
@ -63,13 +63,12 @@ export default class DHWeapon extends AttachableItem {
] ]
} }
} }
}), })
actions: new ActionsField()
}; };
} }
get actionsList() { get actionsList() {
return new Set([this.attack, ...this.actions]); return [this.attack, ...this.actions];
} }
get customActions() { get customActions() {

View file

@ -123,9 +123,9 @@ export default class DHItem extends foundry.documents.Item {
} }
async use(event) { async use(event) {
const actions = this.system.actionsList; const actions = new Set(this.system.actionsList);
if (actions?.size) { if (actions?.size) {
let action = actions.first(0); let action = actions.first();
if (actions.size > 1 && !event?.shiftKey) { if (actions.size > 1 && !event?.shiftKey) {
// Actions Choice Dialog // Actions Choice Dialog
action = await this.selectActionDialog(event); action = await this.selectActionDialog(event);