Utilisation nullish / chaining

Simplifie certaines expressions complexes avec operateur ternaire

- Nullish coalescing operator (??)
- Relationship with the optional chaining operator (?.)

- Math.min / Math.max / Math.ceil
This commit is contained in:
Vincent Vandemeulebrouck
2021-01-04 14:10:21 +01:00
parent 0ef119f59c
commit e3439953f9
6 changed files with 27 additions and 33 deletions

View File

@ -122,7 +122,7 @@ export class RdDResolutionTable {
list.push({ label: surprise.descr, value: surprise.attaque });
}
if (rollData.diffLibre != undefined) {
const label = rollData.selectedSort ? rollData.selectedSort.name : 'Libre';
const label = rollData.selectedSort?.name ?? 'Libre';
list.push({ label: label, value: rollData.diffLibre });
}
if (rollData.diffConditions != undefined) {
@ -131,11 +131,11 @@ export class RdDResolutionTable {
if (rollData.etat != undefined) {
list.push({ label: 'Etat', value: rollData.etat });
}
if (rollData.selectedCarac != undefined && rollData.moral != undefined && rollData.selectedCarac.label == 'Volonté') {
list.push({ label: 'Moral', value: rollData.selectedCarac != undefined && rollData.moral != undefined && rollData.selectedCarac.label == 'Volonté' ? rollData.moral : undefined });
if (rollData.selectedCarac?.label == 'Volonté' && rollData.moral != undefined) {
list.push({ label: 'Moral', value: rollData.moral });
}
if (RdDResolutionTable.isAjustementAstrologique(rollData)) {
list.push({ label: 'Astrologique', value: rollData.ajustementAstrologique || 0 });
list.push({ label: 'Astrologique', value: rollData.ajustementAstrologique ?? 0 });
}
if (rollData.rolled.bonus && rollData.selectedSort) {
list.push({ descr: `Bonus de case: ${rollData.rolled.bonus}%` });