mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
Cleanup of damage outcomes add/remove
This commit is contained in:
parent
13a9ddba46
commit
1af377ba2c
1 changed files with 14 additions and 31 deletions
|
|
@ -388,10 +388,8 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
||||||
if (!this.action.damage.parts) return;
|
if (!this.action.damage.parts) return;
|
||||||
|
|
||||||
const outcome = button.dataset.outcome;
|
const outcome = button.dataset.outcome;
|
||||||
const outcomeParts =
|
const source = this.action._source;
|
||||||
outcome === 'default'
|
const outcomeParts = outcome === 'default' ? source.damage.parts : source.damage.altOutcomes[outcome].parts;
|
||||||
? this.action._source.damage.parts
|
|
||||||
: this.action._source.damage.altOutcomes[outcome].parts;
|
|
||||||
const choices = getUnusedDamageTypes(outcomeParts);
|
const choices = getUnusedDamageTypes(outcomeParts);
|
||||||
const content = new foundry.data.fields.StringField({
|
const content = new foundry.data.fields.StringField({
|
||||||
label: game.i18n.localize('Damage Type'),
|
label: game.i18n.localize('Damage Type'),
|
||||||
|
|
@ -412,32 +410,23 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
||||||
const type = choices[button.form.elements.type.value].value;
|
const type = choices[button.form.elements.type.value].value;
|
||||||
const part = this.action.schema.fields.damage.fields.parts.element.getInitialValue();
|
const part = this.action.schema.fields.damage.fields.parts.element.getInitialValue();
|
||||||
part.applyTo = type;
|
part.applyTo = type;
|
||||||
if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id)
|
if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
||||||
part.type = this.action.schema.fields.damage.fields.parts.element.fields.type.element.initial;
|
part.type = this.action.schema.fields.damage.fields.parts.element.fields.type.element.initial;
|
||||||
|
|
||||||
if (outcome === 'default') data.damage.parts[type] = part;
|
|
||||||
else {
|
|
||||||
if (!data.damage.altOutcomes[outcome]) {
|
|
||||||
data.damage.altOutcomes[outcome] = new AltDamageOutcome();
|
|
||||||
}
|
|
||||||
|
|
||||||
data.damage.altOutcomes[outcome].parts[type] = part;
|
|
||||||
}
|
}
|
||||||
|
if (outcome !== 'default') data.damage.altOutcomes[outcome] ??= new AltDamageOutcome();
|
||||||
|
(outcome === 'default' ? data.damage : data.damage.altOutcomes[outcome]).parts[type] = part;
|
||||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||||
};
|
};
|
||||||
|
|
||||||
const typeDialog = new foundry.applications.api.DialogV2({
|
const typeDialog = new foundry.applications.api.DialogV2({
|
||||||
buttons: [
|
buttons: [
|
||||||
foundry.utils.mergeObject(
|
{
|
||||||
{
|
action: 'ok',
|
||||||
action: 'ok',
|
label: 'Confirm',
|
||||||
label: 'Confirm',
|
icon: 'fas fa-check',
|
||||||
icon: 'fas fa-check',
|
default: true,
|
||||||
default: true
|
callback
|
||||||
},
|
}
|
||||||
{ callback: callback }
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
content: content,
|
content: content,
|
||||||
rejectClose: false,
|
rejectClose: false,
|
||||||
|
|
@ -455,14 +444,8 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
||||||
if (!this.action.damage.parts) return;
|
if (!this.action.damage.parts) return;
|
||||||
const data = this.action.toObject();
|
const data = this.action.toObject();
|
||||||
const { key, outcome } = button.dataset;
|
const { key, outcome } = button.dataset;
|
||||||
if (outcome === 'default') {
|
const parts = outcome === 'default' ? data.damage.parts : data.damage.altOutcomes[outcome].parts;
|
||||||
delete data.damage.parts[key];
|
parts[key] = _del;
|
||||||
data.damage.parts[`${key}`] = _del;
|
|
||||||
} else {
|
|
||||||
delete data.damage.altOutcomes[outcome].parts[key];
|
|
||||||
data.damage.altOutcomes[outcome].parts[`${key}`] = _del;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue