#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:
Vincent Vandemeulebrouck
2021-01-01 03:25:48 +01:00
parent 4ed47a1dd3
commit ee86c0e5ae
14 changed files with 271 additions and 83 deletions

View File

@@ -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));