forked from public/foundryvtt-reve-de-dragon
#13 Support des sorts de difficulte et de cout variables + correction de regression
This commit is contained in:
@ -67,6 +67,21 @@ export class RdDRollDialog extends Dialog {
|
||||
rollData.finalLevel = rollLevel;
|
||||
rollData.finalLevelStr = (rollLevel > 0 ? "+" : "") + rollLevel;
|
||||
rollData.rollTarget = RdDResolutionTable.computeChances(rollData.selectedCarac.value, rollData.finalLevel);
|
||||
|
||||
// Sort management
|
||||
if ( rollData.selectedSort ) {
|
||||
//console.log("Toggle show/hide", rollData.selectedSort);
|
||||
if (rollData.selectedSort.data.difficulte.toLowerCase() == "variable") {
|
||||
$("#div-sort-difficulte").show();
|
||||
} else {
|
||||
$("#div-sort-difficulte").hide();
|
||||
}
|
||||
if (rollData.selectedSort.data.ptreve.toLowerCase() == "variable") {
|
||||
$("#div-sort-ptreve").show();
|
||||
} else {
|
||||
$("#div-sort-ptreve").hide();
|
||||
}
|
||||
}
|
||||
|
||||
$("#roll-param").text(rollData.selectedCarac.value + " / " + rollData.finalLevelStr);
|
||||
$("#compdialogTitle").text(RdDRollDialog._getTitle(rollData));
|
||||
@ -79,41 +94,44 @@ export class RdDRollDialog extends Dialog {
|
||||
// Update html, according to data
|
||||
if (rollData.competence) {
|
||||
// Set the default carac from the competence item
|
||||
console.log("RdDDialogRoll", rollData.competence.data.defaut_carac, rollData.carac);
|
||||
|
||||
//console.log("RdDDialogRoll", rollData.competence.data.defaut_carac, rollData.carac);
|
||||
rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
|
||||
$("#carac").val(rollData.competence.data.defaut_carac);
|
||||
}
|
||||
$("#bonusmalus").val(rollData.bmValue);
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
|
||||
|
||||
// Update !
|
||||
html.find('#bonusmalus').click((event) => {
|
||||
rollData.bmValue = event.currentTarget.value; // Update the selected bonus/malus
|
||||
console.debug("RdDRollDialog","BM CLICKED !!!", rollData);
|
||||
//console.log("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);
|
||||
this.rollData.selectedCarac = rollData.carac[caracKey]; // Update the selectedCarac
|
||||
//console.log("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);
|
||||
let draconicKey = Number(event.currentTarget.value);
|
||||
this.rollData.selectedDraconic = rollData.draconicList[draconicKey]; // Update the selectedCarac
|
||||
//console.log("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);
|
||||
let sortKey = Number(event.currentTarget.value);
|
||||
this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
|
||||
//console.log("RdDRollDialog - Sort selection", rollData.selectedSort);
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#ptreve-variable').click((event) => {
|
||||
let ptreve = Number(event.currentTarget.value);
|
||||
this.rollData.selectedSort.data.ptreve_reel = ptreve; // Update the selectedCarac
|
||||
console.log("RdDRollDialog - Cout reve", ptreve);
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -123,7 +141,11 @@ export class RdDRollDialog extends Dialog {
|
||||
return etat + parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue);
|
||||
}
|
||||
if (rollData.draconicList) {
|
||||
return etat + parseInt(rollData.selectedDraconic.data.niveau) + parseInt(rollData.selectedSort.data.difficulte);
|
||||
let difficulte = rollData.selectedSort.data.difficulte; // Sort de difficulté variable
|
||||
if (difficulte.toLowerCase() == "variable") {
|
||||
difficulte = parseInt(rollData.bmValue); // Récupérer la valeur de la listbox dans ce cas
|
||||
}
|
||||
return etat + parseInt(rollData.selectedDraconic.data.niveau) + parseInt(difficulte);
|
||||
}
|
||||
return etat + parseInt(rollData.bmValue);
|
||||
}
|
||||
|
Reference in New Issue
Block a user