#44 - Gestion sur encombrement corrigée

This commit is contained in:
2020-11-27 12:23:22 +01:00
9 changed files with 65 additions and 35 deletions

View File

@ -1,3 +1,4 @@
import { RdDItemSort } from "./item-sort.js";
import { Misc } from "./misc.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js";
@ -72,12 +73,12 @@ export class RdDRollDialog extends Dialog {
// Sort management
if ( rollData.selectedSort ) {
//console.log("Toggle show/hide", rollData.selectedSort);
if (rollData.selectedSort.data.difficulte.toLowerCase() == "variable") {
if (RdDItemSort.isDifficulteVariable(rollData.selectedSort)) {
$("#div-sort-difficulte").show();
} else {
$("#div-sort-difficulte").hide();
}
if (rollData.selectedSort.data.ptreve.toLowerCase() == "variable" || rollData.selectedSort.data.ptreve.indexOf("+")>=0) {
if (RdDItemSort.isCoutVariable(rollData.selectedSort)) {
$("#div-sort-ptreve").show();
} else {
$("#div-sort-ptreve").hide();
@ -88,6 +89,7 @@ export class RdDRollDialog extends Dialog {
$("#compdialogTitle").text(RdDRollDialog._getTitle(rollData));
$(".table-resolution").remove();
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel));
}
// Setup everything onload
@ -99,9 +101,7 @@ export class RdDRollDialog extends Dialog {
rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
$("#carac").val(rollData.competence.data.defaut_carac);
}
// Si sort, for les points de reve à 1
if (rollData.selectedSort && !rollData.selectedSort.data.ptreve_reel)
rollData.selectedSort.data.ptreve_reel = 1;
RdDItemSort.setCoutReveReel(rollData.selectedSort);
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
$("#diffConditions").val(Misc.toInt(rollData.diffConditions));
updateRollResult(rollData);
@ -133,12 +133,13 @@ export class RdDRollDialog extends Dialog {
html.find('#sort').change((event) => {
let sortKey = Misc.toInt(event.currentTarget.value);
this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
RdDItemSort.setCoutReveReel(rollData.selectedSort);
//console.log("RdDRollDialog - Sort selection", rollData.selectedSort);
updateRollResult(rollData);
});
html.find('#ptreve-variable').change((event) => {
let ptreve = Misc.toInt(event.currentTarget.value);
this.rollData.selectedSort.data.ptreve_reel = ptreve; // Update the selectedCarac
this.rollData.selectedSort.data.ptreve_reel = ptreve;
console.log("RdDRollDialog - Cout reve", ptreve);
updateRollResult(rollData);
});
@ -159,18 +160,19 @@ export class RdDRollDialog extends Dialog {
/* -------------------------------------------- */
static _computeFinalLevel(rollData) {
let etat = Misc.toInt(rollData.etat);
const diffLibre = Misc.toInt(rollData.diffLibre);
const etat = Misc.toInt(rollData.etat);
const diffConditions = Misc.toInt(rollData.diffConditions);
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
let diffLibre = Misc.toInt(rollData.diffLibre);
let diffCompetence = 0;
if (rollData.competence) {
return etat + Misc.toInt(rollData.competence.data.niveau) + diffLibre + diffConditions + malusEnc;
diffCompetence = Misc.toInt(rollData.competence.data.niveau);
}
if (rollData.draconicList) {
let diffSort = (rollData.selectedSort.data.difficulte.toLowerCase() == "variable") ? diffLibre : Misc.toInt(rollData.selectedSort.data.difficulte);
return etat + Misc.toInt(rollData.selectedDraconic.data.niveau) + diffSort + diffConditions;
else if (rollData.draconicList) {
diffCompetence = Misc.toInt(rollData.selectedDraconic.data.niveau);
diffLibre = RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
}
return etat + diffLibre + diffConditions + malusEnc;
return etat + diffCompetence + diffLibre + diffConditions + malusEnc;
}
/* -------------------------------------------- */