mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Functioning setup
This commit is contained in:
parent
4b92001f97
commit
0cb7ede933
24 changed files with 350 additions and 72 deletions
|
|
@ -19,7 +19,8 @@ export default class DHActionConfig extends DHActionBaseConfig {
|
|||
return context;
|
||||
}
|
||||
|
||||
static async addEffect(_event) {
|
||||
static async addEffect(event) {
|
||||
const { areaIndex } = event.target.dataset;
|
||||
if (!this.action.effects) return;
|
||||
const data = this.action.toObject();
|
||||
|
||||
|
|
@ -27,7 +28,10 @@ export default class DHActionConfig extends DHActionBaseConfig {
|
|||
game.system.api.data.activeEffects.BaseEffect.getDefaultObject()
|
||||
]);
|
||||
|
||||
data.effects.push({ _id: created[0]._id });
|
||||
if (areaIndex !== undefined)
|
||||
data.area[areaIndex].effects.push(created[0]._id);
|
||||
else
|
||||
data.effects.push({ _id: created[0]._id });
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
this.action.item.effects.get(created[0]._id).sheet.render(true);
|
||||
}
|
||||
|
|
@ -52,9 +56,20 @@ export default class DHActionConfig extends DHActionBaseConfig {
|
|||
|
||||
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.action.item.deleteEmbeddedDocuments('ActiveEffect', [effectId]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue