diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index c128668a..3367b6a2 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -118,9 +118,21 @@ export class RdDResolutionTable { rolled.finalLevel = finalLevel; rolled.bonus = bonus; rolled.factorHtml = Misc.getFractionHtml(diviseur); + rolled.niveauNecessaire = this.findNiveauNecessaire(caracValue, rolled.roll ); + rolled.ajustementNecessaire = rolled.niveauNecessaire - finalLevel; return rolled; } + /* -------------------------------------------- */ + static findNiveauNecessaire(caracValue, rollValue) { + for (let cell of this.resolutionTable[caracValue]) { + if ( rollValue <= cell.norm) { + return cell.niveau; + } + } + return 16; // Dummy default + } + /* -------------------------------------------- */ static _updateChancesFactor(chances, diviseur) { if (chances.level > -11 && diviseur && diviseur > 1) { @@ -137,11 +149,13 @@ export class RdDResolutionTable { } } + /* -------------------------------------------- */ static significativeRequise(chances) { chances.roll = Math.floor(chances.score / 2); mergeObject(chances, reussites.find(x => x.code == 'sign'), { overwrite: true }); } + /* -------------------------------------------- */ static succesRequis(chances) { chances.roll = chances.score; mergeObject(chances, reussites.find(x => x.code == 'norm'), { overwrite: true }); diff --git a/module/rdd-roll-resolution-table.js b/module/rdd-roll-resolution-table.js index ad2eface..8521e1b1 100644 --- a/module/rdd-roll-resolution-table.js +++ b/module/rdd-roll-resolution-table.js @@ -105,6 +105,8 @@ export class RdDRollResolutionTable extends Dialog { this.updateRollResult(); }); } + + /* -------------------------------------------- */ async updateRollResult() { let rollData = this.rollData; rollData.caracValue = parseInt(rollData.selectedCarac.value) @@ -127,6 +129,7 @@ export class RdDRollResolutionTable extends Dialog { return diffLibre + diffConditions; } + /* -------------------------------------------- */ _computeDiffLibre(rollData) { return Misc.toInt(rollData.diffLibre); } diff --git a/templates/chat-infojet.html b/templates/chat-infojet.html index ea13ceb3..9785ecfa 100644 --- a/templates/chat-infojet.html +++ b/templates/chat-infojet.html @@ -22,4 +22,5 @@