From 1d8468c191e6715e92aaa3fdf3b8ab9c5487b310 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 12 Nov 2020 23:37:12 +0100 Subject: [PATCH] =?UTF-8?q?Table=20r=C3=A9solution=20contextuelle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit level - 5 à level + 5 toujours la colonne -8 --- module/rdd-resolution-table.js | 33 +++++++++++++++++++++++++++------ module/rdd-roll-dialog.js | 10 +++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index f49b4748..a2427989 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -151,6 +151,10 @@ export class RdDResolutionTable { } /* -------------------------------------------- */ + static buildHTMLTableExtract(caracValue, levelValue) { + return this.buildHTMLTable(caracValue, levelValue, caracValue - 2, caracValue + 2, levelValue - 5, levelValue + 5) + } + static buildHTMLTable(caracValue, levelValue, minCarac = 1, maxCarac = 21, minLevel = -10, maxLevel = 11) { return this._buildHTMLTable(caracValue, levelValue, minCarac, maxCarac, minLevel, maxLevel) } @@ -162,7 +166,7 @@ export class RdDResolutionTable { minLevel = Math.max(minLevel, -10); maxLevel = Math.min(maxLevel, 22); - var table = $("") + let table = $("
") .append(this._buildHTMLHeader(this.resolutionTable[0], minLevel, maxLevel)); for (var carac = minCarac; carac <= maxCarac; carac++) { @@ -172,8 +176,16 @@ export class RdDResolutionTable { } static _buildHTMLHeader(dataRow, minLevel, maxLevel) { - var tr = $(""); - for (var difficulte = minLevel; difficulte <= maxLevel; difficulte++) { + let tr = $(""); + let max = maxLevel; + + if (minLevel > -8) { + tr.append($(""); - for (var difficulte = minLevel; difficulte <= maxLevel; difficulte++) { - var td = $(""); + let max = maxLevel; + + if (minLevel > -8) { + let score = dataRow[-8 + 10].score; + tr.append($("
").text("-8")) + } + if (minLevel > -7) { + tr.append($("").text("...")); + } + for (let difficulte = minLevel; difficulte <= max; difficulte++) { const niveau = dataRow[difficulte + 10].niveau; const txt = (niveau > 0 ? "+" : "") + niveau; tr.append($("").text(txt)); @@ -182,9 +194,18 @@ export class RdDResolutionTable { } static _buildHTMLRow(dataRow, rowIndex, caracValue, levelValue, minLevel, maxLevel) { - var tr = $("
"); + let tr = $("
").text(score)) + } + if (minLevel > -7) { + tr.append($("")) + } + for (let difficulte = minLevel; difficulte <= max; difficulte++) { + let td = $(""); let score = dataRow[difficulte + 10].score; if (rowIndex == caracValue && levelValue == difficulte) { td.addClass('table-resolution-target'); diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js index d56978be..3aeb287e 100644 --- a/module/rdd-roll-dialog.js +++ b/module/rdd-roll-dialog.js @@ -71,7 +71,7 @@ export class RdDRollDialog extends Dialog { $("#roll-param").text(rollData.selectedCarac.value + " / " + rollData.finalLevelStr); $("#compdialogTitle").text(RdDRollDialog._getTitle(rollData)); $(".table-resolution").remove(); - $("#resolutionTable").append(RdDResolutionTable.buildHTMLTable(caracValue, rollLevel, caracValue - 2, caracValue + 2)); + $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel)); } // Setup everything onload @@ -91,25 +91,25 @@ export class RdDRollDialog extends Dialog { // Update ! html.find('#bonusmalus').click((event) => { rollData.bmValue = event.currentTarget.value; // Update the selected bonus/malus - console.debug("RdDRollDialog","BM CLICKED !!!", rollData.bmValue, rollData.competence.data.niveau, parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue) ); + console.debug("RdDRollDialog","BM CLICKED !!!", rollData); updateRollResult(rollData); }); html.find('#carac').click((event) => { let caracKey = event.currentTarget.value; rollData.selectedCarac = rollData.carac[caracKey]; // Update the selectedCarac - console.debug("RdDRollDialog","CARAC CLICKED !!!", rollData.selectedCarac, rollData.competence.data.niveau, rollData.bmValue); + console.debug("RdDRollDialog","CARAC CLICKED !!!", rollData); updateRollResult(rollData); }); html.find('#draconic').click((event) => { let draconicKey = event.currentTarget.value; rollData.selectedDraconic = rollData.draconicList[draconicKey]; // Update the selectedCarac - console.debug("RdDRollDialog","CARAC CLICKED !!!", rollData.selectedCarac, rollData.competence.data.niveau, rollData.bmValue); + console.debug("RdDRollDialog","CARAC CLICKED !!!", rollData); updateRollResult(rollData); }); html.find('#sort').click((event) => { let sortKey = event.currentTarget.value; rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac - console.debug("RdDRollDialog","CARAC CLICKED !!!", rollData.selectedCarac, rollData.competence.data.niveau, rollData.bmValue); + console.debug("RdDRollDialog","CARAC CLICKED !!!", rollData); updateRollResult(rollData); });