From f22622710aeff74d43c80453a6f5ca7cb976ddbf Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 28 May 2021 09:12:18 +0200 Subject: [PATCH] Affichage niveau min necessaire #188 --- module/rdd-resolution-table.js | 14 ++++++++++++++ module/rdd-roll-resolution-table.js | 3 +++ templates/chat-infojet.html | 1 + 3 files changed, 18 insertions(+) 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 @@
{{rolled.roll}} : {{rolled.quality}} + (Min.:{{numberFormat rolled.niveauNecessaire decimals=0 sign=true}}/{{numberFormat rolled.ajustementNecessaire decimals=0 sign=true}})
\ No newline at end of file