mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Run lint fix on action areas PR (#1820)
This commit is contained in:
parent
f348b64aae
commit
c57266e596
14 changed files with 72 additions and 66 deletions
|
|
@ -94,9 +94,12 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
|
|||
},
|
||||
{ nullable: true, initial: null }
|
||||
),
|
||||
targetDispositions: new fields.SetField(new fields.NumberField({
|
||||
choices: CONFIG.DH.GENERAL.simpleDispositions,
|
||||
}), { label: 'Affected Dispositions' }),
|
||||
targetDispositions: new fields.SetField(
|
||||
new fields.NumberField({
|
||||
choices: CONFIG.DH.GENERAL.simpleDispositions
|
||||
}),
|
||||
{ label: 'Affected Dispositions' }
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default class DHAbilityUse extends foundry.abstract.TypeDataModel {
|
|||
actor: new fields.StringField(),
|
||||
item: new fields.StringField(),
|
||||
action: new fields.StringField()
|
||||
}),
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ export default class AreaField extends fields.ArrayField {
|
|||
initial: CONFIG.DH.GENERAL.range.veryClose.id,
|
||||
label: 'DAGGERHEART.ACTIONS.Config.area.size'
|
||||
}),
|
||||
effects: new fields.ArrayField(new fields.DocumentIdField()),
|
||||
effects: new fields.ArrayField(new fields.DocumentIdField())
|
||||
});
|
||||
super(element, options, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ export function ActionMixin(Base) {
|
|||
source: {
|
||||
actor: this.actor.uuid,
|
||||
item: this.item.id,
|
||||
action: this.id,
|
||||
action: this.id
|
||||
},
|
||||
itemOrigin: this.item,
|
||||
description: this.description || (this.item instanceof Item ? this.item.system.description : '')
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export { default as applyActiveEffect } from './applyActiveEffect.mjs';
|
||||
export { default as applyActiveEffect } from './applyActiveEffect.mjs';
|
||||
|
|
|
|||
|
|
@ -1,38 +1,40 @@
|
|||
export default class DhApplyActiveEffect extends CONFIG.RegionBehavior.dataModels.applyActiveEffect {
|
||||
static async #getApplicableEffects(token) {
|
||||
const effects = await Promise.all(this.effects.map(foundry.utils.fromUuid));
|
||||
return effects.filter(effect => !effect.system.targetDispositions.size || effect.system.targetDispositions.has(token.disposition));
|
||||
return effects.filter(
|
||||
effect => !effect.system.targetDispositions.size || effect.system.targetDispositions.has(token.disposition)
|
||||
);
|
||||
}
|
||||
|
||||
static async #onTokenEnter(event) {
|
||||
if ( !event.user.isSelf ) return;
|
||||
const {token, movement} = event.data;
|
||||
if (!event.user.isSelf) return;
|
||||
const { token, movement } = event.data;
|
||||
const actor = token.actor;
|
||||
if ( !actor ) return;
|
||||
if (!actor) return;
|
||||
const resumeMovement = movement ? token.pauseMovement() : undefined;
|
||||
const effects = await DhApplyActiveEffect.#getApplicableEffects.bind(this)(event.data.token);
|
||||
const toCreate = [];
|
||||
for ( const effect of effects ) {
|
||||
const data = effect.toObject();
|
||||
delete data._id;
|
||||
if ( effect.compendium ) {
|
||||
data._stats.duplicateSource = null;
|
||||
data._stats.compendiumSource = effect.uuid;
|
||||
} else {
|
||||
data._stats.duplicateSource = effect.uuid;
|
||||
data._stats.compendiumSource = null;
|
||||
for (const effect of effects) {
|
||||
const data = effect.toObject();
|
||||
delete data._id;
|
||||
if (effect.compendium) {
|
||||
data._stats.duplicateSource = null;
|
||||
data._stats.compendiumSource = effect.uuid;
|
||||
} else {
|
||||
data._stats.duplicateSource = effect.uuid;
|
||||
data._stats.compendiumSource = null;
|
||||
}
|
||||
data._stats.exportSource = null;
|
||||
data.origin = this.parent.uuid;
|
||||
toCreate.push(data);
|
||||
}
|
||||
data._stats.exportSource = null;
|
||||
data.origin = this.parent.uuid;
|
||||
toCreate.push(data);
|
||||
}
|
||||
if ( toCreate.length ) await actor.createEmbeddedDocuments("ActiveEffect", toCreate);
|
||||
if (toCreate.length) await actor.createEmbeddedDocuments('ActiveEffect', toCreate);
|
||||
await resumeMovement?.();
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static events = {
|
||||
...CONFIG.RegionBehavior.dataModels.applyActiveEffect.events,
|
||||
[CONST.REGION_EVENTS.TOKEN_ENTER]: this.#onTokenEnter,
|
||||
};
|
||||
}
|
||||
/** @override */
|
||||
static events = {
|
||||
...CONFIG.RegionBehavior.dataModels.applyActiveEffect.events,
|
||||
[CONST.REGION_EVENTS.TOKEN_ENTER]: this.#onTokenEnter
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue