Chance actuelle

+ amélioration show/hide: dispo pour toute application
 (Dialog, Sheet)
This commit is contained in:
2020-12-06 18:41:54 +01:00
parent c5c6d6208d
commit 29eb489b27
5 changed files with 120 additions and 115 deletions

View File

@ -1,3 +1,4 @@
import { HtmlUtility } from "./html-utility.js";
import { RdDItemSort } from "./item-sort.js";
import { Misc } from "./misc.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js";
@ -72,25 +73,12 @@ export class RdDRollDialog extends Dialog {
rollData.finalLevel = rollLevel;
rollData.caracValue = caracValue
if (RdDRollDialog._isEtatGeneralApplicable(rollData)) {
$(".etat-general").show();
}
else {
$(".etat-general").hide();
}
HtmlUtility._showControlWhen(".etat-general", !RdDRollDialog._isIgnoreEtatGeneral(rollData));
// Sort management
if ( rollData.selectedSort ) {
//console.log("Toggle show/hide", rollData.selectedSort);
if (RdDItemSort.isDifficulteVariable(rollData.selectedSort)) {
$("#div-sort-difficulte").show();
} else {
$("#div-sort-difficulte").hide();
}
if (RdDItemSort.isCoutVariable(rollData.selectedSort)) {
$("#div-sort-ptreve").show();
} else {
$("#div-sort-ptreve").hide();
}
HtmlUtility._showControlWhen("#div-sort-difficulte",RdDItemSort.isDifficulteVariable(rollData.selectedSort));
HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort));
}
// Mise à jour valeurs
@ -173,16 +161,13 @@ export class RdDRollDialog extends Dialog {
});
}
static _isEtatGeneralApplicable(rollData) {
if (rollData.selectedCarac.label == 'Chance') return false;
if (rollData.selectedCarac.label == 'Rêve Actuel') return false;
return true;
static _isIgnoreEtatGeneral(rollData) {
return rollData.selectedCarac.ignoreEtatGeneral;
}
/* -------------------------------------------- */
static _computeFinalLevel(rollData) {
const etat = RdDRollDialog._isEtatGeneralApplicable(rollData) ? Misc.toInt(rollData.etat) : 0;
const etat = RdDRollDialog._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat);
const diffConditions = Misc.toInt(rollData.diffConditions);
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
let diffLibre = Misc.toInt(rollData.diffLibre);