#42 Amélioration messages de tchat
* Appel à la chance * compétences * jets généraux (remplace table résolution, carac et cas particuliers) * Attaque: en cours
This commit is contained in:
@@ -11,7 +11,7 @@ const titleTableDeResolution = 'Table de résolution';
|
||||
export class RdDRollResolution extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async open(rollData = {selectedCarac:10}) {
|
||||
static async open(rollData = {}) {
|
||||
RdDRollResolution._setDefaultOptions(rollData);
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html', rollData);
|
||||
const dialog = new RdDRollResolution(rollData, html);
|
||||
@@ -21,8 +21,9 @@ export class RdDRollResolution extends Dialog {
|
||||
/* -------------------------------------------- */
|
||||
static _setDefaultOptions(rollData) {
|
||||
|
||||
|
||||
let defRollData = {
|
||||
show: {title: titleTableDeResolution, points:true},
|
||||
show: { title: titleTableDeResolution, points: true },
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
etat: 0,
|
||||
@@ -30,15 +31,19 @@ export class RdDRollResolution extends Dialog {
|
||||
carac: {},
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
diffLibre: 0
|
||||
diffLibre: 0,
|
||||
}
|
||||
mergeObject(rollData, defRollData, {overwrite: false});
|
||||
mergeObject(rollData, defRollData, { overwrite: false });
|
||||
for (let i = 1; i < 21; i++) {
|
||||
rollData.carac[i] = { type: "number", value: i, label: i }
|
||||
if (rollData.selectedCarac == i) {
|
||||
rollData.selectedCarac = rollData.carac[i];
|
||||
}
|
||||
const key = `${i}`;
|
||||
rollData.carac[key] = { type: "number", value: i, label: key }
|
||||
}
|
||||
let selected = (rollData.selectedCarac && rollData.selectedCarac.label)
|
||||
? rollData.selectedCarac.label
|
||||
: (Number.isInteger(rollData.selectedCarac))
|
||||
? rollData.selectedCarac
|
||||
: 10;
|
||||
rollData.selectedCarac = rollData.carac[selected];
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -59,7 +64,7 @@ export class RdDRollResolution extends Dialog {
|
||||
async onAction(html) {
|
||||
await RdDResolutionTable.rollData(this.rollData);
|
||||
console.log("RdDRollResolution -=>", this.rollData, this.rollData.rolled);
|
||||
const message = { content: await RdDResolutionTable.explainRollDataV2(this.rollData)};
|
||||
const message = { content: await RdDResolutionTable.explainRollDataV2(this.rollData) };
|
||||
ChatUtility.chatWithRollMode(message, game.user.name)
|
||||
}
|
||||
|
||||
@@ -75,7 +80,7 @@ export class RdDRollResolution extends Dialog {
|
||||
function updateRollResult(rollData) {
|
||||
rollData.caracValue = parseInt(rollData.selectedCarac.value)
|
||||
rollData.finalLevel = dialog._computeFinalLevel(rollData);
|
||||
|
||||
|
||||
// Mise à jour valeurs
|
||||
$("#carac").val(rollData.caracValue);
|
||||
$("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel));
|
||||
@@ -84,7 +89,7 @@ export class RdDRollResolution extends Dialog {
|
||||
$(".span-valeur").remove();
|
||||
$("#resolutionValeurs").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel));
|
||||
}
|
||||
|
||||
|
||||
// Setup everything onload
|
||||
$(function () {
|
||||
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
|
||||
|
||||
Reference in New Issue
Block a user