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

@ -66,11 +66,11 @@ export class RdDBonus {
/* -------------------------------------------- */
static _dmgArme(rollData) {
return rollData.arme ? parseInt(rollData.arme.data.dommages) : 0;
return parseInt(rollData.arme?.data.dommages ?? 0);
}
static _peneration(rollData) {
return rollData.arme ? parseInt(rollData.arme.data.penetration) : 0;
return parseInt(rollData.arme?.data.penetration ?? 0);
}
/* -------------------------------------------- */