Simplify handling of optional values in a couple of places

This commit is contained in:
Johannes Loher 2021-02-18 13:36:36 +01:00
parent 24d8926645
commit b2490a2e2f
2 changed files with 5 additions and 7 deletions

View file

@ -73,11 +73,9 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Data<DS4Actor>> {
}
protected _getTooltipForValue(value: ModifiableMaybeData<number | null>): string {
return `${value.base ?? 0} (${game.i18n.localize("DS4.TooltipBaseValue")}) + ${
value.mod ?? 0
} (${game.i18n.localize("DS4.TooltipModifier")}) ${game.i18n.localize("DS4.TooltipEffects")} ${
value.total ?? 0
}`;
return `${value.base} (${game.i18n.localize("DS4.TooltipBaseValue")}) + ${value.mod} (${game.i18n.localize(
"DS4.TooltipModifier",
)}) ${game.i18n.localize("DS4.TooltipEffects")} ${value.total}`;
}
/** @override */

View file

@ -26,9 +26,9 @@ export class DS4Item extends Item<DS4ItemData> {
/**
* The number of times that active effect changes originating from this item should be applied.
*/
get activeEffectFactor(): number {
get activeEffectFactor(): number | undefined {
if (this.data.type === "talent") {
return this.data.data.rank.total ?? this.data.data.rank.base + this.data.data.rank.mod;
return this.data.data.rank.total;
}
return 1;
}