Healing updates

This commit is contained in:
Dapoolp 2025-07-27 23:31:38 +02:00
parent 8cb4b7663e
commit 9d0d35d1a7
21 changed files with 146 additions and 86 deletions

View file

@ -2,8 +2,11 @@ import { DHDamageData } from './damageField.mjs';
const fields = foundry.data.fields;
export default class HealingField extends fields.EmbeddedDataField {
export default class HealingField extends fields.SchemaField {
constructor(options, context = {}) {
super(DHDamageData, options, context);
const healingFields = {
parts: new fields.ArrayField(new fields.EmbeddedDataField(DHDamageData))
};
super(healingFields, options, context);
}
}

View file

@ -17,11 +17,13 @@ export default class TargetField extends fields.SchemaField {
if (!this.target?.type) return [];
let targets;
if (this.target?.type === CONFIG.DH.ACTIONS.targetTypes.self.id)
targets = TargetField.formatTarget.call(this, this.actor.token ?? this.actor.prototypeToken);
targets = Array.from(game.user.targets);
if (this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
targets = targets.filter(t => TargetField.isTargetFriendly.call(this, t));
if (this.target.amount && targets.length > this.target.amount) targets = [];
targets = [this.actor.token ?? this.actor.prototypeToken];
else {
targets = Array.from(game.user.targets);
if (this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
targets = targets.filter(t => TargetField.isTargetFriendly.call(this, t));
if (this.target.amount && targets.length > this.target.amount) targets = [];
}
}
config.targets = targets.map(t => TargetField.formatTarget.call(this, t));
const hasTargets = TargetField.checkTargets.call(this, this.target.amount, config.targets);

View file

@ -200,7 +200,7 @@ export function ActionMixin(Base) {
}
);
const created = await parent.parent.update({ [`system.actions.${action.id}`]: action.toObject() });
const newAction = parent.actions.get(action.id);
const newAction = created.system.actions.get(action.id);
if (!newAction) return null;
if (renderSheet) newAction.sheet.render({ force: true });
return newAction;
@ -215,10 +215,7 @@ export function ActionMixin(Base) {
await this.parent.updateSource({ [path]: updates }, options);
result = this.parent;
} else {
/* Fix me - For some reason updating the "healing" section in particular doesn't work without this */
await this.item.update({ [path]: updates }, options);
await this.item.updateSource({ [path]: updates }, options);
result = this.item;
result = await this.item.update({ [path]: updates }, options);
}
return this.inCollection