Simplify active effect application slightly

This commit is contained in:
Johannes Loher 2021-02-18 13:42:59 +01:00
parent b2490a2e2f
commit d5af9c90c4

View file

@ -39,15 +39,13 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
this.overrides = {}; this.overrides = {};
this.applyActiveEffectsFiltered( this.applyActiveEffectsFiltered(
(change) => (change) =>
!this.derivedDataProperties.includes(change.key) && !this.finalDerivedProperties.includes(change.key), !this.derivedDataProperties.includes(change.key) &&
!this.finalDerivedDataProperties.includes(change.key),
); );
} }
applyActiveEffectsToDerivedData(): void { applyActiveEffectsToDerivedData(): void {
this.applyActiveEffectsFiltered( this.applyActiveEffectsFiltered((change) => this.derivedDataProperties.includes(change.key));
(change) =>
this.derivedDataProperties.includes(change.key) && !this.finalDerivedProperties.includes(change.key),
);
} }
/** /**
@ -108,9 +106,7 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
* The list of properties that are derived from others, given in dot notation. * The list of properties that are derived from others, given in dot notation.
*/ */
get derivedDataProperties(): Array<string> { get derivedDataProperties(): Array<string> {
return Object.keys(DS4.i18n.combatValues) return Object.keys(DS4.i18n.combatValues).map((combatValue) => `data.combatValues.${combatValue}.total`);
.map((combatValue) => `data.combatValues.${combatValue}.total`)
.concat("data.combatValues.hitPoints.max");
} }
/** /**
@ -124,7 +120,7 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
* The list of properties that are completely derived (i.e. {@link ActiveEffect}s cannot be applied to them), * The list of properties that are completely derived (i.e. {@link ActiveEffect}s cannot be applied to them),
* given in dot notation. * given in dot notation.
*/ */
get finalDerivedProperties(): string[] { get finalDerivedDataProperties(): string[] {
return ["data.combatValues.hitPoints.max"]; return ["data.combatValues.hitPoints.max"];
} }