diff --git a/module/actor-sheet.js b/module/actor-sheet.js index bf904505..97519218 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -14,7 +14,7 @@ export class RdDActorSheet extends ActorSheet { template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html", width: 640, height: 720, - tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}], + tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac"}], dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}] }); } @@ -53,10 +53,12 @@ export class RdDActorSheet extends ActorSheet { list = []; data.competenceByCategory[item.data.categorie] = list; } - competenceXPTotal += RdDUtility.computeCompetenceXPCost(item) + if (!RdDUtility.isTronc( item.name ) ) // Ignorer les compétences 'troncs' à ce stade + competenceXPTotal += RdDUtility.computeCompetenceXPCost(item) list.push(item); } } + competenceXPTotal += RdDUtility.computeCompetenceTroncXP(data.itemsByType.competence); data.data.competenceXPTotal = competenceXPTotal; //console.log("XP competence : ", competenceXPTotal); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 09ef92fe..a55a7bd2 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -252,6 +252,27 @@ export class RdDUtility { return xp; } + /* -------------------------------------------- */ + static computeCompetenceTroncXP( competenceList ) + { + let xp = 0; + for (let troncList of competenceTroncs) { + let minNiveau = 15; + for (let troncName of troncList) { + let comp = RdDUtility.findCompetence( competenceList, troncName); + minNiveau = (comp.data.niveau < minNiveau) ? comp.data.niveau : minNiveau; + } + if ( minNiveau > 0 ) 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; + } + } + return xp; + } + /* -------------------------------------------- */ static computeCarac( data) { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 7e48578b..01d37531 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -17,7 +17,7 @@