From 5004774a1534a566244ea5db096df9b7de4ee8e9 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Wed, 16 Oct 2024 23:29:18 +0200 Subject: [PATCH] Rendu des tables de compendiums --- changelog.md | 1 + module/settings/system-compendiums.js | 18 +++++++++--------- module/tmr-rencontres.js | 2 +- ...> chat-compendium-table-roll-rencontre.hbs} | 0 ...oll.html => chat-compendium-table-roll.hbs} | 0 ...um-table.html => chat-compendium-table.hbs} | 7 ++++--- 6 files changed, 15 insertions(+), 13 deletions(-) rename templates/{chat-compendium-table-roll-rencontre.html => chat-compendium-table-roll-rencontre.hbs} (100%) rename templates/{chat-compendium-table-roll.html => chat-compendium-table-roll.hbs} (100%) rename templates/{chat-compendium-table.html => chat-compendium-table.hbs} (59%) diff --git a/changelog.md b/changelog.md index 354259e2..6992eb93 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ - Les messages de maladies ne sont plus publics - Les messages privés dans les TMR sont aussi envoyés au GM - Les informations de compétences pouvant augmenter s'affichent comme tooltips +- Amélioration du rendu des tables de compendiums (commande /table) ## 12.0.14 - Les légions d'Astrobazzarh - Feuille de PNJ: diff --git a/module/settings/system-compendiums.js b/module/settings/system-compendiums.js index 2a405b06..5fa34329 100644 --- a/module/settings/system-compendiums.js +++ b/module/settings/system-compendiums.js @@ -236,12 +236,12 @@ export class CompendiumTableHelpers { let max = 0; const total = rows.map(it => it.frequence).reduce(Misc.sum(), 0); return rows.map(row => { - const frequence = row.frequence; - row.min = max + 1; - row.max = max + frequence; + const frequence = row.frequence + row.min = max + 1 + row.max = max + frequence row.total = total - max += frequence; - return row; + max += frequence + return row }) } static async getRandom(table, type, subTypes = ['objet'], forcedRoll = undefined, localisation = undefined) { @@ -260,8 +260,8 @@ export class CompendiumTableHelpers { } const total = table[0].total; const formula = `1d${total}`; - if (forcedRoll == undefined && (forcedRoll > total || forcedRoll <= 0)) { - ui.notifications.warn(`Jet de rencontre ${forcedRoll} en dehors de la table [1..${total}], le jet est relancé`); + if (forcedRoll != undefined && (forcedRoll > total || forcedRoll <= 0)) { + ui.notifications.warn(`Jet forcé ${forcedRoll} en dehors de la table [1..${total}], le jet est relancé`); forcedRoll = undefined; } const roll = forcedRoll ? { total: forcedRoll, formula } : await RdDDice.roll(formula, { showDice: HIDE_DICE }); @@ -276,7 +276,7 @@ export class CompendiumTableHelpers { return; } const percentages = (row.total == 100) ? '%' : '' - const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll.html', { + const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll.hbs', { roll: row.roll, document: row.document, percentages, @@ -296,7 +296,7 @@ export class CompendiumTableHelpers { /* -------------------------------------------- */ static async tableToChatMessage(table, type, subTypes, typeName = undefined) { - const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table.html', { + const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table.hbs', { img: RdDItem.getDefaultImg(subTypes[0]), typeName: typeName ?? Misc.typeName(type, subTypes[0]), table, diff --git a/module/tmr-rencontres.js b/module/tmr-rencontres.js index 4610d6f4..ef8ea61a 100644 --- a/module/tmr-rencontres.js +++ b/module/tmr-rencontres.js @@ -105,7 +105,7 @@ export class TMRRencontres { /* -------------------------------------------- */ async $chatRolledRencontre(row, rencontre, tmr) { - const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll-rencontre.html', + const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll-rencontre.hbs', { roll: row.roll, rencontre, diff --git a/templates/chat-compendium-table-roll-rencontre.html b/templates/chat-compendium-table-roll-rencontre.hbs similarity index 100% rename from templates/chat-compendium-table-roll-rencontre.html rename to templates/chat-compendium-table-roll-rencontre.hbs diff --git a/templates/chat-compendium-table-roll.html b/templates/chat-compendium-table-roll.hbs similarity index 100% rename from templates/chat-compendium-table-roll.html rename to templates/chat-compendium-table-roll.hbs diff --git a/templates/chat-compendium-table.html b/templates/chat-compendium-table.hbs similarity index 59% rename from templates/chat-compendium-table.html rename to templates/chat-compendium-table.hbs index ef61f351..1e822b66 100644 --- a/templates/chat-compendium-table.html +++ b/templates/chat-compendium-table.hbs @@ -11,9 +11,10 @@