mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/allow action healing multiple resources (#437)
* Healing updates * Remove comments
This commit is contained in:
parent
f55698af02
commit
fad64c9a35
21 changed files with 130 additions and 98 deletions
|
|
@ -169,8 +169,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
},
|
||||
dialog: {},
|
||||
type: this.type,
|
||||
hasDamage: !!this.damage?.parts?.length,
|
||||
hasHealing: !!this.healing,
|
||||
hasDamage: this.damage?.parts?.length && this.type !== 'healing',
|
||||
hasHealing: this.damage?.parts?.length && this.type === 'healing',
|
||||
hasEffect: !!this.effects?.length,
|
||||
hasSave: this.hasSave,
|
||||
selectedRollMode: game.settings.get('core', 'rollMode'),
|
||||
|
|
|
|||
|
|
@ -47,11 +47,12 @@ export default class DHDamageAction extends DHBaseAction {
|
|||
formulas = this.formatFormulas(formulas, systemData);
|
||||
|
||||
const config = {
|
||||
title: game.i18n.format('DAGGERHEART.UI.Chat.damageRoll.title', { damage: game.i18n.localize(this.name) }),
|
||||
title: game.i18n.format(`DAGGERHEART.UI.Chat.${ this.type === 'healing' ? 'healing' : 'damage'}Roll.title`, { damage: game.i18n.localize(this.name) }),
|
||||
roll: formulas,
|
||||
targets: systemData.targets?.filter(t => t.hit) ?? data.targets,
|
||||
hasSave: this.hasSave,
|
||||
isCritical: systemData.roll?.isCritical ?? false,
|
||||
isHealing: this.type === 'healing',
|
||||
source: systemData.source,
|
||||
data: this.getRollData(),
|
||||
event
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
import DHBaseAction from './baseAction.mjs';
|
||||
import DHDamageAction from './damageAction.mjs';
|
||||
|
||||
export default class DHHealingAction extends DHBaseAction {
|
||||
static extraSchemas = [...super.extraSchemas, 'target', 'effects', 'healing', 'roll'];
|
||||
export default class DHHealingAction extends DHDamageAction {
|
||||
static extraSchemas = [...super.extraSchemas, 'roll'];
|
||||
|
||||
static getRollType(parent) {
|
||||
return 'spellcast';
|
||||
}
|
||||
|
||||
/* static extraSchemas = [...super.extraSchemas, 'target', 'effects', 'healing', 'roll'];
|
||||
|
||||
static getRollType(parent) {
|
||||
return 'spellcast';
|
||||
|
|
@ -44,5 +51,5 @@ export default class DHHealingAction extends DHBaseAction {
|
|||
|
||||
get modifiers() {
|
||||
return [];
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export default class DHDamageRoll extends foundry.abstract.TypeDataModel {
|
|||
),
|
||||
targetSelection: new fields.BooleanField({ initial: true }),
|
||||
hasSave: new fields.BooleanField({ initial: false }),
|
||||
isHealing: new fields.BooleanField({ initial: false }),
|
||||
onSave: new fields.StringField(),
|
||||
source: new fields.SchemaField({
|
||||
actor: new fields.StringField(),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue