This commit is contained in:
Dapoolp 2025-08-17 11:52:12 +02:00
parent 1228eb0105
commit 810d74baa5
11 changed files with 220 additions and 17 deletions

View file

@ -176,7 +176,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
// }
// Consume resources
// await this.consume(config);
await this.consume(config);
if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return;
@ -229,9 +229,9 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
// return roll;
// }
doFollowUp(config) {
return !config.hasRoll;
}
// doFollowUp(config) {
// return !config.hasRoll;
// }
async consume(config, successCost = false) {
const actor= this.actor.system.partner ?? this.actor,
@ -301,13 +301,6 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
get hasDamagePart() {
return this.damage?.parts?.length;
}
get modifiers() {
if (!this.actor) return [];
const modifiers = [];
/** Placeholder for specific bonuses **/
return modifiers;
}
/* ROLL */
/* SAVE */

View file

@ -3,7 +3,7 @@ import FormulaField from '../formulaField.mjs';
const fields = foundry.data.fields;
export default class DamageField extends fields.SchemaField {
static order = 50;
static order = 20;
constructor(options, context = {}) {
const damageFields = {

View file

@ -1,7 +1,7 @@
const fields = foundry.data.fields;
export default class EffectsField extends fields.ArrayField {
static order = 100;
static order = 60;
constructor(options = {}, context = {}) {
const element = new fields.SchemaField({
@ -20,4 +20,45 @@ export default class EffectsField extends fields.ArrayField {
return;
}
}
async applyEffects(data, targets) {
targets ??= data.system.targets;
const force = true; /* Where should this come from? */
if (!this.effects?.length || !targets.length) return;
let effects = this.effects;
targets.forEach(async token => {
if (!token.hit && !force) return;
if (this.hasSave && token.saved.success === true) {
effects = this.effects.filter(e => e.onSave === true);
}
if (!effects.length) return;
effects.forEach(async e => {
const actor = canvas.tokens.get(token.id)?.actor,
effect = this.item.effects.get(e._id);
if (!actor || !effect) return;
await this.applyEffect(effect, actor);
});
});
}
async applyEffect(effect, actor) {
const existingEffect = actor.effects.find(e => e.origin === effect.uuid);
if (existingEffect) {
return effect.update(
foundry.utils.mergeObject({
...effect.constructor.getInitialDuration(),
disabled: false
})
);
}
// Otherwise, create a new effect on the target
const effectData = foundry.utils.mergeObject({
...effect.toObject(),
disabled: false,
transfer: false,
origin: effect.uuid
});
await ActiveEffect.implementation.create(effectData, { parent: actor });
}
}

View file

@ -1,7 +1,7 @@
const fields = foundry.data.fields;
export default class MacroField extends fields.DocumentUUIDField {
static order = 200;
static order = 70;
constructor(context = {}) {
super({ type: "Macro" }, context);

View file

@ -1,7 +1,7 @@
const fields = foundry.data.fields;
export default class SaveField extends fields.SchemaField {
static order = 75;
static order = 50;
constructor(options = {}, context = {}) {
const saveFields = {

View file

@ -80,6 +80,78 @@ export default class DhAutomation extends foundry.abstract.DataModel {
initial: CONFIG.DH.GENERAL.defeatedConditions.defeated.id,
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.defeated.companionDefault.label'
})
}),
roll: new fields.SchemaField({
roll: new fields.SchemaField({
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.roll.label',
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.roll.hint',
gm: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.gm'
}),
players: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.player.plurial'
})
}),
damage: new fields.SchemaField({
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damage.label',
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damage.hint',
gm: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.gm'
}),
players: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.player.plurial'
})
}),
save: new fields.SchemaField({
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.save.label',
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.save.hint',
gm: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.gm'
}),
players: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.player.plurial'
})
}),
damageApply: new fields.SchemaField({
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damageApply.label',
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damageApply.hint',
gm: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.gm'
}),
players: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.player.plurial'
})
}),
effect: new fields.SchemaField({
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.effect.label',
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.effect.hint',
gm: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.gm'
}),
players: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.player.plurial'
})
})
})
};
}