mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-22 23:43:37 +02:00
Fixes
This commit is contained in:
parent
cac00e4b30
commit
58b855389d
8 changed files with 52 additions and 24 deletions
|
|
@ -25,7 +25,7 @@ export default class DHActionConfig extends DHActionBaseConfig {
|
|||
const data = this.action.toObject();
|
||||
|
||||
const created = await this.action.item.createEmbeddedDocuments('ActiveEffect', [
|
||||
game.system.api.data.activeEffects.BaseEffect.getDefaultObject()
|
||||
game.system.api.data.activeEffects.BaseEffect.getDefaultObject({ transfer: false })
|
||||
]);
|
||||
|
||||
if (areaIndex !== undefined)
|
||||
|
|
|
|||
|
|
@ -31,21 +31,38 @@ export default class DHActionSettingsConfig extends DHActionBaseConfig {
|
|||
}
|
||||
|
||||
static async addEffect(_event) {
|
||||
const { areaIndex } = event.target.dataset;
|
||||
if (!this.action.effects) return;
|
||||
const effectData = game.system.api.data.activeEffects.BaseEffect.getDefaultObject();
|
||||
|
||||
const effectData = game.system.api.data.activeEffects.BaseEffect.getDefaultObject({ transfer: false });
|
||||
const data = this.action.toObject();
|
||||
|
||||
this.sheetUpdate(data, effectData);
|
||||
this.effects = [...this.effects, effectData];
|
||||
data.effects.push({ _id: effectData.id });
|
||||
|
||||
if(areaIndex !== undefined)
|
||||
data.area[areaIndex].effects.push(effectData.id);
|
||||
else
|
||||
data.effects.push({ _id: effectData.id });
|
||||
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
}
|
||||
|
||||
static removeEffect(event, button) {
|
||||
if (!this.action.effects) return;
|
||||
const index = button.dataset.index,
|
||||
const { areaIndex, index } = button.dataset;
|
||||
let effectId = null;
|
||||
if (areaIndex !== undefined) {
|
||||
effectId = this.action.area[areaIndex].effects[index];
|
||||
const data = this.action.toObject();
|
||||
data.area[areaIndex].effects.splice(index, 1);
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
} else {
|
||||
effectId = this.action.effects[index]._id;
|
||||
this.constructor.removeElement.bind(this)(event, button);
|
||||
this.constructor.removeElement.bind(this)(event, button);
|
||||
}
|
||||
|
||||
|
||||
this.sheetUpdate(
|
||||
this.action.toObject(),
|
||||
this.effects.find(x => x.id === effectId),
|
||||
|
|
|
|||
|
|
@ -134,13 +134,14 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
|
|||
return armorChange.getArmorData();
|
||||
}
|
||||
|
||||
static getDefaultObject() {
|
||||
static getDefaultObject(options = { transfer: true }) {
|
||||
return {
|
||||
name: 'New Effect',
|
||||
id: foundry.utils.randomID(),
|
||||
disabled: false,
|
||||
img: 'icons/magic/life/heart-cross-blue.webp',
|
||||
description: '',
|
||||
transfer: options.transfer,
|
||||
statuses: [],
|
||||
changes: [],
|
||||
system: {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export default class DhApplyActiveEffect extends CONFIG.RegionBehavior.dataModels.applyActiveEffect {
|
||||
static async #getApplicableEffects(token) {
|
||||
const effects = await Promise.all(this.effects.map(fromUuid));
|
||||
return (effects).filter(effect => !effect.system.targetDispositions.size || effect.system.targetDispositions.has(token.disposition));
|
||||
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));
|
||||
}
|
||||
|
||||
static async #onTokenEnter(event) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ export default class RegisterHandlebarsHelpers {
|
|||
pluralize: this.pluralize,
|
||||
positive: this.positive,
|
||||
isNullish: this.isNullish,
|
||||
debug: this.debug,
|
||||
});
|
||||
}
|
||||
static add(a, b) {
|
||||
|
|
@ -93,9 +92,4 @@ export default class RegisterHandlebarsHelpers {
|
|||
static isNullish(a) {
|
||||
return a === null || a === undefined;
|
||||
}
|
||||
|
||||
static debug(a) {
|
||||
console.log(a);
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue