mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Add multiple conditions handler + update Bare Bones domain card
This commit is contained in:
parent
af3a415e56
commit
4a63836c0d
8 changed files with 213 additions and 38 deletions
|
|
@ -20,7 +20,12 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ['daggerheart', 'sheet', 'dh-style']
|
||||
classes: ['daggerheart', 'sheet', 'dh-style'],
|
||||
actions: {
|
||||
addCondition: DhActiveEffectConfig.#onAddCondition,
|
||||
deleteCondition: DhActiveEffectConfig.#onDeleteCondition,
|
||||
setAndOr: DhActiveEffectConfig.#setAndOr
|
||||
}
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
|
|
@ -115,4 +120,46 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
|
||||
return partContext;
|
||||
}
|
||||
|
||||
/* ----------------------------------------- */
|
||||
|
||||
/**
|
||||
* Add a new condition to the effect's conditions array.
|
||||
* @this {DhActiveEffectConfig}
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #onAddCondition() {
|
||||
const submitData = this._processFormData(null, this.form, new foundry.applications.ux.FormDataExtended(this.form));
|
||||
const conditions = Object.values(submitData.system.conditional?.condition ?? {});
|
||||
conditions.push({});
|
||||
return this.submit({updateData: {'system.conditional.condition': conditions}});
|
||||
}
|
||||
|
||||
/* ----------------------------------------- */
|
||||
|
||||
/**
|
||||
* Add a new condition to the effect's conditions array.
|
||||
* @this {DhActiveEffectConfig}
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #onDeleteCondition(event) {
|
||||
const submitData = this._processFormData(null, this.form, new FormDataExtended(this.form));
|
||||
const conditions = Object.values(submitData.system.conditional.condition ?? {});
|
||||
const row = event.target.closest("li");
|
||||
const index = Number(row.dataset.index) || 0;
|
||||
conditions.splice(index, 1);
|
||||
return this.submit({updateData: {'system.conditional.condition': conditions}});
|
||||
}
|
||||
|
||||
/* ----------------------------------------- */
|
||||
|
||||
/**
|
||||
* Add a new condition to the effect's conditions array.
|
||||
* @this {DhActiveEffectConfig}
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #setAndOr(event) {
|
||||
const value = event.target.dataset.value;
|
||||
return this.submit({updateData: {'system.conditional.andOr': value === 'true'}});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue