Table résolution contextuelle

level - 5 à level + 5
toujours la colonne -8
This commit is contained in:
Vincent Vandemeulebrouck 2020-11-12 23:37:12 +01:00
parent a9d005310f
commit 1d8468c191
2 changed files with 32 additions and 11 deletions

View File

@ -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) { static buildHTMLTable(caracValue, levelValue, minCarac = 1, maxCarac = 21, minLevel = -10, maxLevel = 11) {
return this._buildHTMLTable(caracValue, levelValue, minCarac, maxCarac, minLevel, maxLevel) return this._buildHTMLTable(caracValue, levelValue, minCarac, maxCarac, minLevel, maxLevel)
} }
@ -162,7 +166,7 @@ export class RdDResolutionTable {
minLevel = Math.max(minLevel, -10); minLevel = Math.max(minLevel, -10);
maxLevel = Math.min(maxLevel, 22); maxLevel = Math.min(maxLevel, 22);
var table = $("<table class='table-resolution'/>") let table = $("<table class='table-resolution'/>")
.append(this._buildHTMLHeader(this.resolutionTable[0], minLevel, maxLevel)); .append(this._buildHTMLHeader(this.resolutionTable[0], minLevel, maxLevel));
for (var carac = minCarac; carac <= maxCarac; carac++) { for (var carac = minCarac; carac <= maxCarac; carac++) {
@ -172,8 +176,16 @@ export class RdDResolutionTable {
} }
static _buildHTMLHeader(dataRow, minLevel, maxLevel) { static _buildHTMLHeader(dataRow, minLevel, maxLevel) {
var tr = $("<tr/>"); let tr = $("<tr/>");
for (var difficulte = minLevel; difficulte <= maxLevel; difficulte++) { let max = maxLevel;
if (minLevel > -8) {
tr.append($("<th class='table-resolution-level'/>").text("-8"))
}
if (minLevel > -7) {
tr.append($("<th class='table-resolution-level'/>").text("..."));
}
for (let difficulte = minLevel; difficulte <= max; difficulte++) {
const niveau = dataRow[difficulte + 10].niveau; const niveau = dataRow[difficulte + 10].niveau;
const txt = (niveau > 0 ? "+" : "") + niveau; const txt = (niveau > 0 ? "+" : "") + niveau;
tr.append($("<th class='table-resolution-level'/>").text(txt)); tr.append($("<th class='table-resolution-level'/>").text(txt));
@ -182,9 +194,18 @@ export class RdDResolutionTable {
} }
static _buildHTMLRow(dataRow, rowIndex, caracValue, levelValue, minLevel, maxLevel) { static _buildHTMLRow(dataRow, rowIndex, caracValue, levelValue, minLevel, maxLevel) {
var tr = $("<tr/>"); let tr = $("<tr/>");
for (var difficulte = minLevel; difficulte <= maxLevel; difficulte++) { let max = maxLevel;
var td = $("<td/>");
if (minLevel > -8) {
let score = dataRow[-8 + 10].score;
tr.append($("<td class='table-resolution-carac'/>").text(score))
}
if (minLevel > -7) {
tr.append($("<td/>"))
}
for (let difficulte = minLevel; difficulte <= max; difficulte++) {
let td = $("<td/>");
let score = dataRow[difficulte + 10].score; let score = dataRow[difficulte + 10].score;
if (rowIndex == caracValue && levelValue == difficulte) { if (rowIndex == caracValue && levelValue == difficulte) {
td.addClass('table-resolution-target'); td.addClass('table-resolution-target');

View File

@ -71,7 +71,7 @@ export class RdDRollDialog extends Dialog {
$("#roll-param").text(rollData.selectedCarac.value + " / " + rollData.finalLevelStr); $("#roll-param").text(rollData.selectedCarac.value + " / " + rollData.finalLevelStr);
$("#compdialogTitle").text(RdDRollDialog._getTitle(rollData)); $("#compdialogTitle").text(RdDRollDialog._getTitle(rollData));
$(".table-resolution").remove(); $(".table-resolution").remove();
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTable(caracValue, rollLevel, caracValue - 2, caracValue + 2)); $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel));
} }
// Setup everything onload // Setup everything onload
@ -91,25 +91,25 @@ export class RdDRollDialog extends Dialog {
// Update ! // Update !
html.find('#bonusmalus').click((event) => { html.find('#bonusmalus').click((event) => {
rollData.bmValue = event.currentTarget.value; // Update the selected bonus/malus 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); updateRollResult(rollData);
}); });
html.find('#carac').click((event) => { html.find('#carac').click((event) => {
let caracKey = event.currentTarget.value; let caracKey = event.currentTarget.value;
rollData.selectedCarac = rollData.carac[caracKey]; // Update the selectedCarac 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); updateRollResult(rollData);
}); });
html.find('#draconic').click((event) => { html.find('#draconic').click((event) => {
let draconicKey = event.currentTarget.value; let draconicKey = event.currentTarget.value;
rollData.selectedDraconic = rollData.draconicList[draconicKey]; // Update the selectedCarac 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); updateRollResult(rollData);
}); });
html.find('#sort').click((event) => { html.find('#sort').click((event) => {
let sortKey = event.currentTarget.value; let sortKey = event.currentTarget.value;
rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac 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); updateRollResult(rollData);
}); });