diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 0c216f6b..f8739ae5 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -396,17 +396,21 @@ export class RdDUtility { { let xp = 0; for (let troncList of competenceTroncs) { - let minNiveau = 15; + let minNiveau = 0; for (let troncName of troncList) { let comp = RdDUtility.findCompetence( competenceList, troncName); - minNiveau = (comp.data.niveau < minNiveau) ? comp.data.niveau : minNiveau; + if (comp) { + minNiveau = Math.min(comp.data.niveau, minNiveau); + } } - if ( minNiveau > 0 ) minNiveau = 0; // Clamp à 0, pour le tronc commun + minNiveau = Math.max(minNiveau, 0); // Clamp à 0, pour le tronc commun let minNiveauXP = competence_xp_par_niveau[minNiveau+10]; xp += minNiveauXP; for (let troncName of troncList) { let comp = RdDUtility.findCompetence( competenceList, troncName); - xp += competence_xp_par_niveau[comp.data.niveau+10] - minNiveauXP; + if (comp){ + xp += competence_xp_par_niveau[comp.data.niveau+10] - minNiveauXP; + } } } return xp;